vladkostashuk

Untitled

Apr 12th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3.  
  4. using namespace std;
  5.  
  6. int mass[50][50];
  7. int h = 15;
  8.  
  9. int r_max = 10;
  10. int r_min = 10;
  11.  
  12. void ChangeRows();
  13. void Mas2Random();
  14.  
  15. void main()
  16. {
  17. #pragma region мова
  18.     SetConsoleCP(1251);
  19.     SetConsoleOutputCP(1251);
  20. #pragma endregion
  21.  
  22.  
  23.     system("pause");
  24. }
  25.  
  26. void Mas2Random()
  27. {
  28.     cout << endl;
  29.     //Зманні максимуму та мінімуму
  30.     int max = 0, min = 0;
  31.     //Вивід повідомлення
  32.     cout << "Введіть мінімум і максимум рандому" << endl;
  33.     //Ввід мінімуму
  34.     cout << "Мінімум = "; cin >> min;
  35.     //Ввід максимуму ранд.
  36.     cout << "Максимум = "; cin >> max;
  37.  
  38.     // Цикл X
  39.     for (int i = 0; i < h; i++)
  40.     {
  41.         // Цикл Y
  42.         for (int o = 0; o < h; o++)
  43.         {
  44.             //Запис рандомного значення в массив
  45.             mass[i][o] = rand() % (max - min) - min;
  46.         }
  47.     }
  48. }
  49.  
  50. void OutputMas2()
  51. {
  52.     cout << endl;
  53.     cout << "Массив:" << endl;
  54.  
  55.     for (int i = 0; i < h; i++)
  56.     {
  57.         for (int o = 0; o < h; o++)
  58.         {
  59.             cout << mass[i][o];
  60.         }
  61.  
  62.         cout << endl;
  63.     }
  64.  
  65.     cout << endl << endl;
  66. }
  67.  
  68. void ChangeRows()
  69. {
  70.     int msd[50], msd1[50];
  71.     bool sd = false;
  72.     int r1 = 0, r2 = 0;
  73.     cout << "Введіть порядкові номера рядків" << endl << "1 рядок" << endl;
  74.     cin >> r1; cout << "Замінити з рядком: " << endl; cin >> r2;
  75.    
  76.  
  77.     for (int i = 0; i < h; i++)
  78.     {
  79.         if (i == r1)
  80.         {
  81.             for (int f = 0; f < h; f++)
  82.             {
  83.                 msd[f] = mass[i][f];
  84.             }
  85.         }
  86.  
  87.         if (i == r2)
  88.         {
  89.             for (int f = 0; f < h; f++)
  90.             {
  91.                 msd1[f] = mass[i][f];
  92.             }
  93.         }
  94.     }
  95.  
  96.     for (int ii = 0; ii < h; ii++)
  97.     {
  98.         if (ii == r1)
  99.         {
  100.             for (int oi = 0; oi < h; oi++)
  101.             {
  102.                 mass[ii][oi] = msd1[oi];
  103.             }
  104.         }
  105.     }
  106.  
  107.     for (int iii = 0; iii < h; iii++)
  108.     {
  109.         if (iii == r2)
  110.         {
  111.             for (int oii = 0; oii < h; oii++)
  112.             {
  113.                 mass[iii][oii] = msd[oii];
  114.             }
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment