Вопрос задан 17.11.2023 в 20:58. Предмет Информатика. Спрашивает Abdygulova Asel.

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

двумерный массив 3. Выведите на экран индексы наименьшего числа и наибольшего числа во всем массиве2.Напишите код1. Вводятся 2 числа - размеры двумерного массива2. Вводится двумерный массив3. Вводится число х3. Выведите на экран количество чисел делящихся на х во всем массиве3.1. Вводятся 2 числа - размеры двумерного массива2. Вводится двумерный массив3. Выведите на экран двумерный массив4.Напишите код1. Задаются числа n и m 2. Создается, заполняется двумерный массив размерами n и m3. Массив поворачивается на 90 градусов по часовой стрелке и показывается на экран5.Напишите кодПроверить симметрична ли матрица относительно обратной диагонали (от правого верхнего угла до левого нижнего угла) и вывести на экран ответ "Yes" или "No"6.1. Вводятся 2 числа - размеры двумерного массива2. Вводится двумерный массив3. Выведите на экран столбцы массива с НЕЧЕТНЫМИ индексами​
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Матий Слава.

Ответ:

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;

}

Объяснение:

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

1. Напишите код: ```c++ #include using namespace std;

int main() { int n, m; cout << "Введите размеры двумерного массива: "; cin >> n >> m; int arr[n][m]; cout << "Введите элементы двумерного массива: " << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> arr[i][j]; } } int minIndexI = 0, minIndexJ = 0; int maxIndexI = 0, maxIndexJ = 0; int minValue = arr[0][0]; int maxValue = arr[0][0]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(arr[i][j] < minValue) { minValue = arr[i][j]; minIndexI = i; minIndexJ = j; } if(arr[i][j] > maxValue) { maxValue = arr[i][j]; maxIndexI = i; maxIndexJ = j; } } } cout << "Наименьшее число: " << minValue << ". Индексы: (" << minIndexI << ", " << minIndexJ << ")" << endl; cout << "Наибольшее число: " << maxValue << ". Индексы: (" << maxIndexI << ", " << maxIndexJ << ")" << endl; return 0; } ```

2. Напишите код: ```c++ #include using namespace std;

int main() { int n, m; cout << "Введите размеры двумерного массива: "; cin >> n >> m; int arr[n][m]; cout << "Введите элементы двумерного массива: " << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> arr[i][j]; } } int x; cout << "Введите число 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 << "Количество чисел, делящихся на " << x << ": " << count << endl; return 0; } ```

3.1. Напишите код: ```c++ #include using namespace std;

int main() { int n, m; cout << "Введите размеры двумерного массива: "; cin >> n >> m; int arr[n][m]; cout << "Введите элементы двумерного массива: " << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> arr[i][j]; } } cout << "Двумерный массив:" << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cout << arr[i][j] << " "; } cout << endl; } return 0; } ```

4. Напишите код: ```c++ #include using namespace std;

int main() { int n, m; cout << "Введите размеры двумерного массива: "; cin >> n >> m; int arr[n][m]; cout << "Введите элементы двумерного массива: " << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> arr[i][j]; } } int rotatedArr[m][n]; for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { rotatedArr[i][j] = arr[n - j - 1][i]; } } cout << "Повернутый на 90 градусов массив:" << endl; for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { cout << rotatedArr[i][j] << " "; } cout << endl; } return 0; } ```

5. Напишите код: ```c++ #include using namespace std;

int main() { int n; cout << "Введите размер квадратной матрицы: "; cin >> n; int arr[n][n]; cout << "Введите элементы матрицы: " << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { cin >> arr[i][j]; } } bool isSymmetric = true; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(arr[i][j] != arr[n - j - 1][n - i - 1]) { isSymmetric = false; break; } } if(!isSymmetric) { break; } } if(isSymmetric) { cout << "Матрица симметрична относительно обратной диагонали" << endl; } else { cout << "Матрица несимметрична относительно обратной диагонали" << endl; } return 0; } ```

6.1. Напишите код: ```c++ #include using namespace std;

int main() { int n, m; cout << "Введите размеры двумерного массива: "; cin >> n >> m; int arr[n][m]; cout << "Введите элементы двумерного массива: " << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> arr[i][j]; } } cout << "Столбцы массива с НЕЧЕТНЫМИ индексами: " << endl; for(int j = 0; j < m; j++) { if(j % 2 != 0) { for(int i = 0; i < n; i++) { cout << arr[i][j] << " "; } cout << endl; } } return 0; } ```

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос