Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
111885 | 陈铎文 | 蛇形矩阵 | C++ | Accepted | 1 MS | 276 KB | 369 | 2025-03-08 09:11:26 |
#include<bits/stdc++.h> using namespace std; int n; int main(){ int a[11][11]={},t=1; cin>>n; for(int i=0;i<n;i++){ if(i%2==0){ for(int j=0;j<n;j++){ a[j][i]=t++; } } else{ for(int j=n-1;j>=0;j--){ a[j][i]=t++; } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ printf("%3d",a[i][j]); } cout<<endl; } }