Created
February 8, 2025 21:00
-
-
Save tuchkaaa3/4b87e8cc45c7783b78f6b1bf1b1c49b6 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> | |
using namespace std; | |
int main() | |
{ | |
//2 | |
const int ROWS = 6; | |
const int COLS = 6; | |
int arr[ROWS][COLS]; | |
int n = 0; | |
int n2 = 0; | |
cout << "Enter number"; | |
cin >> n; | |
arr[0][0] = n; | |
arr[0][0] = n; | |
for (int i = 0; i < ROWS; i++) | |
{ | |
for (int j = 0; j < COLS; j++) //просто + 1 вместо *2... | |
{ | |
if (i == 0 && j == 0) continue; // Первый элемент уже задан | |
if (j == 0) | |
arr[i][j] = arr[i - 1][COLS - 1] + 1; //предыдущее число для начала новой строки1! | |
else | |
arr[i][j] = arr[i][j - 1] + 1; // для всех следующих елементов новой строки после 0!!!! | |
} | |
} | |
//вывод массива | |
for (int i = 0; i < ROWS; i++) | |
{ | |
for (int j = 0; j < ROWS; j++) | |
{ | |
cout << arr[i][j] << ' '; | |
} | |
cout << endl; | |
} | |
//1. const int ROWS = 6; | |
//const int COLS = 6; | |
//int arr[ROWS][COLS]; | |
//int n = 0; | |
//int n2 = 0; | |
//cout << "Enter number"; | |
//cin >> n; | |
//arr[0][0] = n; | |
//arr[0][0] = n; | |
//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; //предыдущее число для начала новой строки1! | |
// else | |
// arr[i][j] = arr[i][j - 1] * 2; // для всех следующих елементов новой строки после 0!!!! | |
// } | |
//} | |
// | |
// | |
////вывод массива | |
//for (int i = 0; i < ROWS; i++) | |
//{ | |
// for (int j = 0; j < ROWS; 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