Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 444 Solved: 381
[Submit][Status][Web Board]
Description
輸入整數N,輸出相應方陣。
Input
一個整數N。( 0 < n < 10 )
Output
一個方陣,每個數字的場寬爲3。
Sample Input
5
Sample Output
5 4 3 2 1
4 4 3 2 1
3 3 3 2 1
2 2 2 2 1
1 1 1 1 1
HINT
\
\
\
\
想法類似拐角1。
代碼:
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
for(int i=a;i>=1;i--)
{
for(int u=a;u>=i;u--)
{
printf("%3d",i);
}
for(int j=i-1;j>=1;j--)
{
printf("%3d",j);
}
cout<<endl;
}
return 0;
}