Created
February 12, 2025 13:40
-
-
Save vlaleli/5b5bfc568bdbaf225756299329b255cf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 1) | |
| #include <iostream> | |
| using namespace std; | |
| int main() { | |
| const int ROWS = 3; | |
| const int COLS = 3; | |
| int arr[ROWS][COLS]; | |
| int num; | |
| cout << "Enter number:"; | |
| cin >> num; | |
| arr[0][0] = num; | |
| for (int i = 0; i < ROWS; i++) { | |
| for (int j = 0; j < COLS; j++) { | |
| if (i == 0 && j == 0) continue; | |
| if (j == 0) | |
| arr[i][j] = arr[i - 1][COLS - 1] * 2; | |
| else | |
| arr[i][j] = arr[i][j - 1] * 2; | |
| } | |
| } | |
| cout << "Created array:" << endl; | |
| for (int i = 0; i < ROWS; i++) { | |
| for (int j = 0; j < COLS; j++) { | |
| cout << arr[i][j] << " "; | |
| } | |
| cout << endl; | |
| } | |
| return 0; | |
| } | |
| 2) | |
| #include <iostream> | |
| using namespace std; | |
| int main() { | |
| const int ROWS = 3; | |
| const int COLS = 3; | |
| int arr[ROWS][COLS]; | |
| int num; | |
| cout << "Enter number: "; | |
| cin >> num; | |
| arr[0][0] = num; | |
| for (int i = 0; i < ROWS; i++) { | |
| for (int j = 0; j < COLS; j++) { | |
| if (i == 0 && j == 0) continue; | |
| if (j == 0) | |
| arr[i][j] = arr[i - 1][COLS - 1] + 1; | |
| else | |
| arr[i][j] = arr[i][j - 1] + 1; | |
| } | |
| } | |
| cout << "Created array:" << endl; | |
| for (int i = 0; i < ROWS; i++) { | |
| for (int j = 0; j < COLS; j++) { | |
| cout << arr[i][j] << " "; | |
| } | |
| cout << endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment