View Code of Problem 53

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a;
    cin >> a;
    int k = 4;
    int s = 1;
    for (int i = 0; i < a - 1; i++) {
	   for (int j = 0; j < k; j++) {
		  cout << " ";
	   }
	   k--;
	   for (int l = 0; l < s; l++) { cout << "*"; }
	   s = s + 2;
	   cout << endl;
    }
    for (int i = 0; i < s; i++) { cout << "*"; }
    cout << endl;
    s = s - 2;
    k++;
    for (int i = 0; i < a - 1; i++) {
	   for (int j = 0; j < k; j++) {
		  cout << " ";
	   }
	   k++;
	   for (int l = 0; l < s; l++) { cout << "*"; }
	   s = s - 2;
	   cout << endl;
    }



    return 0;
}

Double click to view unformatted code.


Back to problem 53