DasShelmer

3.4.19

Oct 13th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     const int maxCollums = 5; // Кол-во столбцов в таблице
  6.     const int rowsForNewCollum = 2; // Кол-во строк для наращивания нового столбца
  7.  
  8.     // Лучше заполнить массив и выводить его значения
  9.     // (Сократит кол-во операций вычисления)
  10.     int nums[maxCollums * 2];
  11.     for (int i = 0, a = 30; i < maxCollums * 2; i += 2, a--) {
  12.         nums[i] = a / 10;
  13.         nums[i + 1] = a % 10;
  14.     }
  15.  
  16.     // Построчный вывод
  17.     int collums = 1; // Счётчик кол-ва столбцов на строке
  18.     for (int j = 0; j < maxCollums * 2; j++) {
  19.         // Условие наращивания столбца
  20.         if (j > 0 && j % rowsForNewCollum == 0)
  21.             collums++;
  22.  
  23.         // Вывод каждого солбца
  24.         for (int h = 0; h < collums; h++)
  25.             cout << nums[j - rowsForNewCollum * h] << " ";
  26.         cout << endl;
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment