• Предмет: Информатика
  • Автор: bomj22876
  • Вопрос задан 4 месяца назад


C++. Отдаю все баллы
1.
Напишите код 1. Вводятся 2 числа - размеры двумерного массива 2. Вводится двумерный массив 3. Выведите на экран индексы наименьшего числа и наибольшего числа во всем массиве

2.

Напишите код

1. Вводятся 2 числа - размеры двумерного массива
2. Вводится двумерный массив
3. Вводится число х
3. Выведите на экран количество чисел делящихся на х во всем массиве


3.
1. Вводятся 2 числа - размеры двумерного массива
2. Вводится двумерный массив
3. Выведите на экран двумерный массив

4.
Напишите код

1. Задаются числа n и m
2. Создается, заполняется двумерный массив размерами n и m

3. Массив поворачивается на 90 градусов по часовой стрелке и показывается на экран

5.
Напишите код

Проверить симметрична ли матрица относительно обратной диагонали (от правого верхнего угла до левого нижнего угла) и вывести на экран ответ "Yes" или "No"

6.
1. Вводятся 2 числа - размеры двумерного массива
2. Вводится двумерный массив
3. Выведите на экран столбцы массива с НЕЧЕТНЫМИ индексами​


aslankobzhanov6: ez bro
aslankobzhanov6: wait

Ответы

Ответ дал: aslankobzhanov6
1

Ответ:

1. #include <iostream>

using namespace std;

void find_min_max(int arr[][10], int rows, int cols) {

   int min_value = INT_MAX;

   int max_value = INT_MIN;

   int min_row = 0, min_col = 0, max_row = 0, max_col = 0;

   for (int i = 0; i < rows; i++) {

       for (int j = 0; j < cols; j++) {

           if (arr[i][j] < min_value) {

               min_value = arr[i][j];

               min_row = i;

               min_col = j;

           }

           if (arr[i][j] > max_value) {

               max_value = arr[i][j];

               max_row = i;

               max_col = j;

           }

       }

   }

   cout << "The smallest number is: " << min_value << " at index [" << min_row << "][" << min_col << "]" << endl;

   cout << "The largest number is: " << max_value << " at index [" << max_row << "][" << max_col << "]" << endl;

}

int main() {

   int rows, cols;

   cout << "Enter the number of rows: ";

   cin >> rows;

   cout << "Enter the number of columns: ";

   cin >> cols;

   int arr[10][10];

   cout << "Enter the elements of the two-dimensional array: " << endl;

   for (int i = 0; i < rows; i++) {

       for (int j = 0; j < cols; j++) {

           cin >> arr[i][j];

       }

   }

   find_min_max(arr, rows, cols);

   return 0;

}

2. #include <iostream>

using namespace std;

int main() {

int n, m;

cout << "Enter the dimensions of the 2D array (n, m): ";

cin >> n >> m;

int arr[n][m];

cout << "Enter the elements of the 2D array: " << endl;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

cin >> arr[i][j];

}

}

int x;

cout << "Enter the number x: ";

cin >> x;

int count = 0;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

if (arr[i][j] % x == 0) {

count++;

}

}

}

cout << "The number of numbers divisible by " << x << " in the entire array is: " << count << endl;

return 0;

}

3. #include <iostream>

using namespace std;

int main() {

int n, m;

cout << "Enter the dimensions of the 2D array (n, m): ";

cin >> n >> m;

int arr[n][m];

cout << "Enter the elements of the 2D array: " << endl;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

cin >> arr[i][j];

}

}

cout << "The 2D array is: " << endl;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

cout << arr[i][j] << " ";

}

cout << endl;

}

return 0;

}
4.#include <iostream>

using namespace std;

int main() {

int n, m;

cout << "Enter the dimensions of the 2D array (n, m): ";

cin >> n >> m;

int arr[n][m];

cout << "Enter the elements of the 2D array: " << endl;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

cin >> arr[i][j];

}

}

cout << "The original 2D array is: " << endl;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

cout << arr[i][j] << " ";

}

cout << endl;

}

cout << "The rotated 2D array is: " << endl;

for (int j = m - 1; j >= 0; j--) {

for (int i = 0; i < n; i++) {

cout << arr[i][j] << " ";

}

cout << endl;

}

return 0;

}
5.#include <iostream>

using namespace std;

int main() {

int n, m;

cout << "Enter the dimensions of the 2D array (n, m): ";

cin >> n >> m;

int arr[n][m];

cout << "Enter the elements of the 2D array: " << endl;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

cin >> arr[i][j];

}

}

bool isSymmetrical = true;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

if (arr[i][j] != arr[j][i]) {

isSymmetrical = false;

break;

}

}

if (!isSymmetrical) {

break;

}

}

if (isSymmetrical) {

cout << "Yes" << endl;

} else {

cout << "No" << endl;

}

return 0;

}

6.
#include <iostream>

using namespace std;

int main() {

int n, m;

cout << "Enter the dimensions of the 2D array (n, m): ";

cin >> n >> m;

int arr[n][m];

cout << "Enter the elements of the 2D array: " << endl;

for (int i = 0; i < n; i++) {

for (int j = 0; j < m; j++) {

cin >> arr[i][j];

}

}

cout << "Columns with odd indices: " << endl;

for (int j = 1; j < m; j += 2) {

for (int i = 0; i < n; i++) {

cout << arr[i][j] << " ";

}

cout << endl;

}

return 0;

}

Объяснение:


bomj22876: Спасибо
Вас заинтересует