22 февраля 2016 г.

Нарисовать звездочками флаг Великобритании.

HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
int digit;
do
{
cout << "Enter digit(only even digit):";
cin >> digit;
} while (digit % 2 == 0);

cout << endl;

for (int i = 0; i < digit; i++)
{
for (int j = 0; j < digit; j++)
{
if (j == i || j == digit - i-1||i==digit/2||j==digit/2)
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | RED));
cout << char(219);

}
else if (i == digit / 2 - 1 || j == digit / 2 - 1 || i == digit / 2 + 1 || j == digit / 2 + 1||
j == i-1 || j == digit - i - 2|| j == i+1 || j == digit - i)
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | WHITE));
cout << char(219);
}
else
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | BLUE));
cout << char(219);
}

}
cout << endl;
}
cout << endl;
system("pause");

Комментариев нет:

Отправить комментарий