Created
February 8, 2025 17:06
-
-
Save rohachevsk/ca677e03e7e52c8ab8f9eae9056f4a71 to your computer and use it in GitHub Desktop.
Напишіть програму, яка створює двовимірний масив і заповнює його за таким принципом: користувач вводить число (наприклад, 3) перший елемент масиву приймає значення цього числа, наступний елемент масиву приймає значення цього числа помноженого на 2 (тобто 6 для нашого прикладу), третій елемент масиву — попередній елемент помножений на 2 (тобто 6*…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
const int rows = 3; | |
const int cols = 3; | |
int n; | |
cout << "enter n ... "; | |
cin >> n; | |
int arr[rows][cols]; | |
for (int i = 0; i < rows; ++i) | |
{ | |
for (int j = 0; j < cols; ++j) | |
{ | |
arr[i][j] = n; | |
n *=2; | |
} | |
} | |
for (int i = 0; i < rows; ++i) | |
{ | |
for (int j = 0; j < cols; ++j) | |
{ | |
cout << arr[i][j] << ' '; | |
} | |
cout << endl; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment