Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
133251 任艺宸 蛇形矩阵 C++ Accepted 2 MS 276 KB 688 2025-10-18 11:20:26

Tests(10/10):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int n,a[11][11]={},t=1; cin>>n; for(int j=0;j<n;j++){ if(j%2==0){ for(int i=0;i<n;i++){ a[i][j]=t++; } }else{ for(int i=n-1;i>=0;i--){ a[i][j]=t++; } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ printf("%3d",a[i][j]); } cout<<endl; } return 0; }