View Code of Problem 57

#include<iostream>
using namespace std;
int main(){
	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n-i;j++){
			cout<<" ";
		}
		for(int k=1;k<=i;k++){
			cout<<k;
		}
		for(int m=i-1;m>0;m--){
			cout<<m;
		}
		cout<<endl;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=i;j++){
			cout<<" ";
		}
		for(int k=1;k<=n-i;k++){
			cout<<k;
		}
		for(int m=n-i-1;m>0;m--){
			cout<<m;
		}
		cout<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 57