Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
6763 黄宜洋 蛇形矩阵 C++ Accepted 0 MS 260 KB 753 2025-03-15 14:33: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]; int t=1; cin>>n; for(int j=1;j<=n;j++){ if(j%2==1){ for(int i=1;i<=n;i++){ a[i][j]=t; t++; } } else{ for(int i=n;i>=1;i--){ a[i][j]=t; t++; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ printf("%3d",a[i][j]); } cout<<endl; } return 0; }