Advertisement
avr39ripe

cpp2DArrFillByMult2

Jul 30th, 2021
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     const int mult{ 2 };
  6.     const int sizeY{ 3 };
  7.     const int sizeX{ 4 };
  8.     int arr[sizeY][sizeX];
  9.  
  10.     std::cout << "Enter starting value:\n";
  11.     std::cin >> arr[0][0];
  12.  
  13.     for (int y{ 0 }; y < sizeY; ++y)
  14.     {
  15.         std::cout << arr[y][0] << '\t';
  16.         for (int x{ 1 }; x < sizeX; ++x)
  17.         {
  18.             std::cout  << (arr[y][x] = arr[y][x - 1] * mult) << '\t';
  19.         }
  20.         std::cout << '\n';
  21.         if (y < sizeY - 1) { arr[y + 1][0] = arr[y][sizeX - 1] * mult; }
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement