Created
February 8, 2025 17:07
-
-
Save rohachevsk/3e7e69b9826516326256791649f6d944 to your computer and use it in GitHub Desktop.
Напишіть програму, яка створює двовимірний масив і заповнює його за таким принципом: користувач вводить число (наприклад, 3) перший елемент масиву приймає значення цього числа, наступний елемент масиву приймає значення цього числа + 1
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 +=1; | |
} | |
} | |
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