View Code of Problem 53

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			cout << " ";
		}
		for (int j = 0; j < 2 * (i + 1) - 1; j++)
		{
			cout << '*';
		}
		cout << endl;
	}
	for (int i = n - 2; i >= 0; i--)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			cout << " ";
		}
		for (int j = 0; j < 2 * (i + 1) - 1; j++)
		{
			cout << '*';
		}
		cout << endl;
	}
	return 0;
}
/*
Main.c:1:20: fatal error: iostream: No such file or directory
 #include <iostream>
                    ^
compilation terminated.
*/

Double click to view unformatted code.


Back to problem 53