View Code of Problem 57

#include<bits/stdc++.h>
using namespace std;
        int main(){    
        	int n;
        	scanf("%d",&n);
        	for(int i = 1;i<=n;i++){  //控制层数 
        		for(int j = i;j<=n-1;j++)cout<<" ";
        		for(int k = 1;k<=i;k++)cout<<k;
        		for(int op = i-1;op>0;op--)cout<<op;
        		cout<<endl;
			}
        	for(int i = 1;i<=n-1;i++){  //控制层数 
        		for(int j = i;j>=1;j--)cout<<" ";
        		for(int k = 1;k<n-i;k++)cout<<k;
        		for(int op = n-i;op>0;op--)cout<<op;
        		cout<<endl;
			}
        	
        	
        	
        	
        	return 0;
        }

Double click to view unformatted code.


Back to problem 57