srand(time(0));
const int columns = 5;
const int lines = 5;
int glav_diag = 0;
int poboch_diag = 0;
int A[lines][columns]{};
cout << "Massive A:" << endl;
for (int i = 0; i < lines; i++) {
}
cout << endl << "Summ glav_diag: " << glav_diag << endl
system("pause");
const int columns = 5;
const int lines = 5;
int glav_diag = 0;
int poboch_diag = 0;
int A[lines][columns]{};
cout << "Massive A:" << endl;
for (int i = 0; i < lines; i++) {
for (int j = 0; j < columns; j++) {
A[i][j] = rand() % 100;}
cout.width(3);
cout << A[i][j];
if (i == j)
glav_diag += A[i][j];
if (j == columns - i - 1)
poboch_diag += A[i][j];
cout << endl;
}
cout << endl << "Summ glav_diag: " << glav_diag << endl
<< "Summ poboch_diag: " << poboch_diag << endl;
system("pause");
Комментариев нет:
Отправить комментарий