View Code of Problem 53

#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int k = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n + k; j++) {
			if (j < n - k-1) {
				cout << " ";
			}
			else {
				cout << "*";
			}
		}
		k++;
		cout << "\n";
	}
	k = n-2;
	for (int i = 0; i < n-1; i++) {
		for (int j = 0; j < n + k; j++) {
			if (j < n - k - 1) {
				cout << " ";
			}
			else {
				cout << "*";
			}
		}
		k--;
		cout << "\n";
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 53