22 февраля 2016 г.

Написать программу, которая выводят на экран флаг Украины (пользователь вводит ширину, высота равна трети ширины), состоящий из символа '*'. То же, но фигура внутри пустая.

HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
int digit;
do
{
cout << "Enter digit(digit>\9):";
cin >> digit;
} while (digit < 10|| (digit / 3 / 2)%2!=0);

for (int i = 0; i <= digit/3; i ++)
{
for (int j = 0; j < digit; j++)
{
if (i <= digit / 3 / 2)
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | L_BLUE));
cout << char(219);
}
else
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | YELLOW));
cout << char(219);
}
}
cout << endl;
}
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | WHITE));
cout << endl << endl;
for (int i = 0; i <= digit / 3; i++)
{
for (int j = 0; j < digit; j++)
{
if (i == 0||(j==0&&i<=digit/3/2)||(j==digit-1 && i <= digit / 3 / 2))
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | L_BLUE));
cout << char(219);
}
else if (i == digit / 3||(j==0&&i>= digit / 3 / 2) || (j == digit - 1 && i >= digit / 3 / 2))
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | YELLOW));
cout << char(219);
}
else
cout << " ";
}
cout << endl;
}
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | WHITE));
system("pause");

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

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