Created
February 6, 2025 13:14
-
-
Save Vinnik67/0cbb35315df38d9e9775a169cedd8ff1 to your computer and use it in GitHub Desktop.
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> | |
int main() | |
{ | |
//1 | |
int n; | |
std::cout << "Enter number: "; | |
std::cin >> n; | |
const int ROWS = 2; | |
const int COLS = 3; | |
int arr[ROWS][COLS]; | |
arr[0][0] = n; | |
for (int i = 0; i < ROWS; ++i) | |
{ | |
for (int j = 0; j < COLS; ++j) | |
{ | |
if (i == 0 && j == 0) | |
{ | |
continue; | |
} | |
else if (j == 0) | |
{ | |
arr[i][j] = arr[i - 1][COLS - 1] * 2; | |
} | |
else | |
{ | |
arr[i][j] = arr[i][j - 1] * 2; | |
} | |
} | |
} | |
std::cout << "Created array:" << std::endl; | |
for (int i = 0; i < ROWS; ++i) | |
{ | |
for (int j = 0; j < COLS; ++j) | |
{ | |
std::cout << arr[i][j] << " "; | |
} | |
std::cout << std::endl; | |
} | |
std::cout << "\n"; | |
//2 | |
int n1; | |
std::cout << "Enter number: "; | |
std::cin >> n1; | |
int arr1[ROWS][COLS]; | |
arr1[0][0] = n1; | |
for (int i = 0; i < ROWS; ++i) | |
{ | |
for (int j = 0; j < COLS; ++j) | |
{ | |
if (i == 0 && j == 0) | |
{ | |
continue; | |
else if (j == 0) | |
{ | |
arr1[i][j] = arr1[i - 1][COLS - 1] + 1; | |
} | |
else | |
{ | |
arr1[i][j] = arr1[i][j - 1] + 1; | |
} | |
} | |
} | |
std::cout << "Created array:" << std::endl; | |
for (int i = 0; i < ROWS; ++i) | |
{ | |
for (int j = 0; j < COLS; ++j) | |
{ | |
std::cout << arr1[i][j] << " "; | |
} | |
std::cout << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment