CCF1032菱形
1032. 菱形 http://oj.noi.cn/oj/#main/show/1032
#include<bits/stdc++.h>
using namespace std;
//微信请加 14808098 一起快乐学习信息学奥赛
int main() {
/*
n = 5
1 1
3 ____123
5 __12345
7 _1234567
9 123456789 m=9
7 m-2
5
3
1
..........
.....
.....
...
..
*/
int n; cin>>n;//n=3
int m = 2*n-1; //m=5
int i,j,k;
for(i=1;i<=m;i=i+2){
for(j=1;j<= (m-i)/2; j++ ){
cout<<" ";
}
for(k=1;k<=i;k++){
cout<<k;
}
cout<<endl;
}
for(i=m-2;i>=1;i=i-2){
for(j=1;j<= (m-i)/2; j++ ){
cout<<" ";
}
for(k=1;k<=i;k++){
cout<<k;
}
cout<<endl;
}
return 0;
}