srand(time(0));
const int size = 5;
int A[size][size]{};
for (size_t i = 0; i < size; i++) {
}
cout << endl << endl;
int summ = 0;
int min = A[0][0];
int max = A[0][0];
int index_min_x, index_min_y;
int index_max_x, index_max_y;
Находим минимальное и максимальное значение и запоминаем координаты
for (size_t i = 0; i < size; i++) {
}
считаем количество элементов
for (size_t i = 0; i < size; i++) {
}
cout << endl << endl;
cout << "Result:" << endl
system("pause");
const int size = 5;
int A[size][size]{};
for (size_t i = 0; i < size; i++) {
for (size_t j = 0; j < size; j++) {
A[i][j] = rand() % 100;}
cout.width(3);
cout << A[i][j];
cout << endl;
}
cout << endl << endl;
int summ = 0;
int min = A[0][0];
int max = A[0][0];
int index_min_x, index_min_y;
int index_max_x, index_max_y;
Находим минимальное и максимальное значение и запоминаем координаты
for (size_t i = 0; i < size; i++) {
for (size_t j = 0; j < size; j++) {
if (min > A[i][j]) {}
min = A[i][j];}
index_min_x = j;
index_min_y = i;
if (max < A[i][j]) {
max = A[i][j];}
index_max_x = j;
index_max_y = i;
}
считаем количество элементов
for (size_t i = 0; i < size; i++) {
for (size_t j = 0; j < size; j++) {
cout.width(3);}
cout << A[i][j];
cout << endl;
}
cout << endl << endl;
cout << "Result:" << endl
<< "index_min_x = " << index_min_x << endl
<< "index_min_y = " << index_min_y << endl
<< "index_max_x = " << index_max_x << endl
<< "index_max_y = " << index_max_y << endl;
system("pause");
Комментариев нет:
Отправить комментарий