Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <iomanip>
- #include <conio.h>
- using namespace std;
- int main(int argc, char* argv[])
- {
- setlocale(LC_ALL, "rus");
- int array[10][11];
- int max = 0;
- int number, counter;
- int key;
- srand(time(NULL));
- for (int i = 1; i < 10; i++)
- {
- for (int j = 0; j < 11; j++)
- {
- array[i][j] = rand() % 241 - 70;
- cout << setw(4) << array[i][j] << " ";
- }
- cout << endl;
- }
- do {
- cout << "Для вывода максимального элемента массива введите 1" << endl;
- cout << "Для сортировки строки массива введите 2" << endl;
- cin >> counter;
- switch (counter)
- {
- case 1:
- for (int i = 1; i < 10; i++)
- {
- for (int j = 0; j < 11; j++)
- if (array[i][j]>max) max = array[i][j];
- }
- cout << "Максимальный элемент массива равен " << max << endl;
- break;
- case 2:
- cout << "Введите номер строки для сортировки" << endl;
- cin >> number;
- for (int i = 0; i < 11; i++)
- {
- int с = array[0][0];
- for (int j = i + 1; j < 11; j++)
- {
- if (array[number][i] > array[number][j])
- {
- с = array[number][i];
- array[number][i] = array[number][j];
- array[number][j] = с;
- }
- }
- }
- for (int i = 1; i < 10; i++)
- {
- for (int j = 0; j < 11; j++)
- cout << setw(4) << array[i][j] << " ";
- cout << endl;
- }
- break;
- default: cout << "Введено неверное значение" << endl;
- }
- cout << endl << "Для продолжения нажмите Enter, или любую другую клавишу для выхода" << endl << endl;
- key = _getch();
- } while (key == 13);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement