输入5,输出: 1 1 1 1 1 1 2 2 2 2 1 2 3 3 3 1 2 3 3 4 1 2 3 4 5
是真么做到的呢?请看以下操作:
#include<bits/stdc++.h>
using namespace std
;
int main()
{
int n
,a
,b
;
cin
>>n
;
for(int i
=1;i
<=n
;i
++)
{
a
=1;
for(int f
=1;f
<i
;f
++)
{
cout
<<setw(3)<<a
;
a
++;
}
for(int j
=i
;j
<=n
;j
++)
cout
<<setw(3)<<a
;
cout
<<endl
;
}
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-42331.html