View Code of Problem 53

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s=""; 
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n-i;j++)
			s.push_back(' ');
		for(int j=1;j<=i*2-1;j++)
			s.push_back('*');
		cout<<s<<endl;
		s.clear();
	}
	for(int i=4;i>=1;i--){
		for(int j=1;j<=n-i;j++)
			s.push_back(' ');
		for(int j=1;j<=i*2-1;j++)
			s.push_back('*');
		cout<<s<<endl;
		s.clear();
	}		
} 

Double click to view unformatted code.


Back to problem 53