View Code of Problem 57

#include<iostream>
#include<iomanip>
#include<string>
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 z=1;z<=i;z++)
			cout<<z;
		for(int k=i-1;k>=1;k--)
			cout<<k;
		cout<<endl;
	}
	for(int i=1;i<n;i++)
	{
		for(int z=1;z<=i;z++)
			cout<<" ";
		for(int j=1;j<=n-i;j++)
		{
			cout<<j;
		}
		for(int k=n-i-1;k>=1;k--)
		{
			cout<<k;
		}
		cout<<endl;
		
	 } 
	
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 57