哪位能帮忙解下,自己思考的实在没有头绪了,特别急
Description
输入整数N,输出相应方阵。
Input
一个整数N。( 0 < n < 10 )
Output
一个方阵,每个数字的场宽为3。
Sample Input
5
Sample Output
5 4 3 2 1
4 5 4 3 2
3 4 5 4 3
2 3 4 5 4
1 2 3 4 5
哪位能帮忙解下,自己思考的实在没有头绪了,特别急
Description
输入整数N,输出相应方阵。
Input
一个整数N。( 0 < n < 10 )
Output
一个方阵,每个数字的场宽为3。
Sample Input
5
Sample Output
5 4 3 2 1
4 5 4 3 2
3 4 5 4 3
2 3 4 5 4
1 2 3 4 5
#include <iostream>
using namespace std;
int main()
{
int num;
cin>>num;
for (int i = 0; i < num; i++)
{
int tmp=num-i;
for (int j = 0; j <num; j++){
if(tmp==num)
cout<<tmp+i-j<<" ";
else{
cout<<tmp<<" ";
tmp++;
}
}
cout<<"\n";
}
}