22 февраля 2016 г.

Тоже самое, но фигура перевернута и пустая внутри.

HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
int length_of_sections, summ_sections;
cout << "Enter summ sections:";
cin >> summ_sections;
do
{
cout << "Enter length of sections(only even digit):";
cin >> length_of_sections;
} while (length_of_sections % 2 == 0);

int front=0;

for (int i = 1; i <= summ_sections; i++)
{
front++;
if (front == 15)
front = 1;

for (int i = 0; i<length_of_sections / 2 + 1; i++)
{
for (int j = 0; j < length_of_sections; j++)
{
if (i == 0 || j == i || j == length_of_sections - i - 1)
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | front));
cout << "*";
}
else
cout << " ";
}
cout <<endl;
}
}
system("pause");

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

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