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;
}