22 февраля 2016 г.

Вывести на экран таблицу умножения от 1 до 9 в виде трех строк и трех колонок.

HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
int front = 1;
for (int i = 1; i <= 9; i+=3)
{
for (int j = 1; j < 10; j++)
{
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | front++));
cout << i << " * " << j << " = " << i*j << "\t";
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | front++));
cout << i + 1 << " * " << j << " = " << (i + 1)*j << "\t";
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | front++));
cout << i + 2 << " * " << 2 << " = " << (i + 2)*j << endl;
front -= 3;
}
cout << endl;
front += 3;
}
SetConsoleTextAttribute(h, (WORD)(BLACK << 4 | WHITE));
system("pause");

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

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