Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- const int maxCollums = 5; // Кол-во столбцов в таблице
- const int rowsForNewCollum = 2; // Кол-во строк для наращивания нового столбца
- // Лучше заполнить массив и выводить его значения
- // (Сократит кол-во операций вычисления)
- int nums[maxCollums * 2];
- for (int i = 0, a = 30; i < maxCollums * 2; i += 2, a--) {
- nums[i] = a / 10;
- nums[i + 1] = a % 10;
- }
- // Построчный вывод
- int collums = 1; // Счётчик кол-ва столбцов на строке
- for (int j = 0; j < maxCollums * 2; j++) {
- // Условие наращивания столбца
- if (j > 0 && j % rowsForNewCollum == 0)
- collums++;
- // Вывод каждого солбца
- for (int h = 0; h < collums; h++)
- cout << nums[j - rowsForNewCollum * h] << " ";
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment