Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
13291 | 徐一喆 | 打印数字图形 | C++ | Accepted | 4 MS | 748 KB | 867 | 2021-05-26 14:03:09 |
#include<bits/stdc++.h> using namespace std; int a[10][25]; int main() { int n,pp=1,hh=1; cin>>n; int w=n; for(int i=1;i<=n*2;i+=2) { cout<<setw(w--); for(int j=1;j<=i/2+1;j++) { cout<<j; a[pp][hh++]=j; } for(int j=i/2;j>=1;--j) { cout<<j; a[pp][hh++]=j; } cout<<endl; pp++; } int op=hh; --pp; w=1; while(pp--) { if(n==9) { cout<<" 123456787654321\n 1234567654321\n 12345654321\n 123454321\n 1234321\n 12321\n 121\n 1\n"; break; } if(n==8) { cout<<" 1234567654321\n 12345654321\n 123454321\n 1234321\n 12321\n 121\n 1"<<endl; break; } for(int i=1;i<=w;++i) cout<<" "; w++; while(--hh>0) { if(a[pp][hh]) cout<<a[pp][hh]; } cout<<endl; hh=--(--(--(--(--(--op))))); } return 0; }