Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
20848 纪哲弘 二维数组输出(4) C++ Accepted 3 MS 736 KB 381 2021-12-12 19:08:14

Tests(4/4):


Code:

#include<iostream> using namespace std; int main(){ int a[11][11],b,c=1; cin>>b; for(int i=0;i<b;i++){ if(i%2==1){ for(int j=b-1;j>=0;j--){ a[i][j]=c; c++; } } else{ for(int j=0;j<b;j++){ a[i][j]=c; c++; } } } for(int i=0;i<b;i++){ for(int j=0;j<b;j++){ cout<<a[i][j]<<' '; } cout<<endl; } return 0; }