Advertisement
ULK

Лабораторная №7 (8.19)

ULK
Jan 15th, 2023 (edited)
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int const m = 11;
  7.     int const n = 4;
  8.     int a[m][n];
  9.  
  10.     for (int i = 0; i < m; i++) //заполнение
  11.     {
  12.         for (int j = 0; j < n; j++)
  13.         {
  14.             a[i][j] = rand() % 30 + 10;
  15.         }
  16.     }
  17.  
  18.     cout << "\t" << " A" << "\t" << "B" << "\t" << "C" << "\t" << "D" << endl; //строка с буквами
  19.  
  20.     for (int i = 0; i < m; i++)
  21.     {
  22.         cout << i + 1 << "\t" << "|"; //столбец с числами
  23.  
  24.         for (int j = 0; j < n; j++)
  25.         {
  26.             cout << a[i][j] << "\t";
  27.         }
  28.         cout << endl;
  29.     }
  30.  
  31.     for (int i = 0; i < m; i++) //каждая параллель
  32.     {
  33.         int min = 100;
  34.         for (int j = 0; j < n; j++)
  35.         {
  36.             if (a[i][j] < min)
  37.             {
  38.                 min = a[i][j];
  39.             }
  40.         }
  41.         cout << "least amount of people amongst " << i + 1 << " classes " << min << endl;
  42.     }
  43.  
  44.     cout << endl;
  45.  
  46.     for (int j = 0; j < n; j++) //каждая буква
  47.     {
  48.         int min = 100;
  49.         for (int i = 0; i < m; i++)
  50.         {
  51.             if (a[i][j] < min)
  52.             {
  53.                 min = a[i][j];
  54.             }
  55.         }
  56.         cout << "least amount of people amongst ";
  57.  
  58.         if (j == 0) //написание буквы класса
  59.         {
  60.                 cout << "A";
  61.         }
  62.         else
  63.         {
  64.             if (j == 1)
  65.             {
  66.                 cout << "B";
  67.             }
  68.             else
  69.             {
  70.                 if (j == 2)
  71.                 {
  72.                     cout << "C";
  73.                 }
  74.                 else
  75.                 {
  76.                     if (j == 3)
  77.                     {
  78.                         cout << "D";
  79.                     }
  80.                 }
  81.             }
  82.         }
  83.  
  84.         cout << " classes " << min << endl;
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement