View Code of Problem 53

#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a=n-1,b=1,c=1,d=n*2-3;
	for(int i=1;i<=n*2-1;i++){
		if(i<=n){
			for(int j=1;j<=a;j++){
				cout<<' ';
			}
			a--;
			for(int j=1;j<=b;j++){
				cout<<'*';
			}
			b+=2;
			cout<<endl;
		}
		else{
			for(int j=1;j<=c;j++){
				cout<<' ';
			}
			c++;
			for(int j=1;j<=d;j++){
				cout<<'*';
			}
			d-=2;
			cout<<endl;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 53