#include<bits/stdc++.h> using namespace std; int main(){ int n,i,j,k; cin>>n; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ cout<<' '; } for(k=1;k<=i+1;k++){ cout<<k; } for(k=i;k>0;k--){ cout<<k; } cout<<endl; } for(i=0;i<n;i++){ for(j=i+1;j>0;j--){ cout<<' '; } for(k=1;k<n-i;k++){ cout<<k; } for(k=n-i-2;k>0;k--){ cout<<k; } cout<<endl; } } |
Double click to view unformatted code.