View Code of Problem 57

#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin>>n;
	int k=1,temp;
	for(int i=1;i<=n;i++){
		k=1;
		//temp=1;
		for(int j=1;j<=n+i-1;j++){
			if(j<=n-i)cout<<" ";
			else{
				cout<<k;
				
				if(j<n){
					k++;	
				}
				else{
					k--;
				}
				
			}
		}
		cout<<'\n';
	}
	//k=1;
	for(int i=1;i<n;i++){
		k=1;
		for(int j=1;j<=2*n-i-1;j++){
			if(j<=i)cout<<" ";
			else{
				cout<<k;
				if(j<n){
					k++;
				}
				else{
					k--;
				}
			}
		}
		cout<<'\n';
	}
	
} 

Double click to view unformatted code.


Back to problem 57