Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- int mass[50][50];
- int h = 15;
- int r_max = 10;
- int r_min = 10;
- void ChangeRows();
- void Mas2Random();
- void main()
- {
- #pragma region мова
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- #pragma endregion
- system("pause");
- }
- void Mas2Random()
- {
- cout << endl;
- //Зманні максимуму та мінімуму
- int max = 0, min = 0;
- //Вивід повідомлення
- cout << "Введіть мінімум і максимум рандому" << endl;
- //Ввід мінімуму
- cout << "Мінімум = "; cin >> min;
- //Ввід максимуму ранд.
- cout << "Максимум = "; cin >> max;
- // Цикл X
- for (int i = 0; i < h; i++)
- {
- // Цикл Y
- for (int o = 0; o < h; o++)
- {
- //Запис рандомного значення в массив
- mass[i][o] = rand() % (max - min) - min;
- }
- }
- }
- void OutputMas2()
- {
- cout << endl;
- cout << "Массив:" << endl;
- for (int i = 0; i < h; i++)
- {
- for (int o = 0; o < h; o++)
- {
- cout << mass[i][o];
- }
- cout << endl;
- }
- cout << endl << endl;
- }
- void ChangeRows()
- {
- int msd[50], msd1[50];
- bool sd = false;
- int r1 = 0, r2 = 0;
- cout << "Введіть порядкові номера рядків" << endl << "1 рядок" << endl;
- cin >> r1; cout << "Замінити з рядком: " << endl; cin >> r2;
- for (int i = 0; i < h; i++)
- {
- if (i == r1)
- {
- for (int f = 0; f < h; f++)
- {
- msd[f] = mass[i][f];
- }
- }
- if (i == r2)
- {
- for (int f = 0; f < h; f++)
- {
- msd1[f] = mass[i][f];
- }
- }
- }
- for (int ii = 0; ii < h; ii++)
- {
- if (ii == r1)
- {
- for (int oi = 0; oi < h; oi++)
- {
- mass[ii][oi] = msd1[oi];
- }
- }
- }
- for (int iii = 0; iii < h; iii++)
- {
- if (iii == r2)
- {
- for (int oii = 0; oii < h; oii++)
- {
- mass[iii][oii] = msd[oii];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment