evcamels

iv

Feb 11th, 2021
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. // Массивы 3 файл ( задачи )
  2.  
  3. #include <iostream>
  4. #include <ctime>
  5. #include <cstdlib>
  6. #include <stdio.h>
  7. #include <algorithm>
  8. #include <vector>
  9. using namespace std;
  10. int main() {
  11.     srand(time(0));
  12.  
  13.     vector <int> a(7);
  14.     int i;
  15.     int c = 0;
  16.     cout << "Массив до сортировки: ";
  17.     for(i = 0;i < 7; i++){
  18.         a[i] = 0 + rand() % 100;
  19.         cout << a[i] << " ";
  20.         if(a[i] >= 25 && a[i] <= 75){
  21.             c++;
  22.         }
  23.     }
  24.     cout << endl << endl;
  25.     cout << "Количество элементов на отрезке [25;75]: " << c;
  26.     cout << endl << endl;
  27.     sort(a.begin(),a.end());
  28.     cout << "Отсортированный массив: ";
  29.     for(int i = 0; i < 7; i++){
  30.         cout << a[i] << " ";
  31.     }
  32.     cout << endl;
  33.     int b[6][4];
  34.     for(int i=0; i<6; i++){
  35.         for (int j=0; j<4; j++){
  36.             b[i][j] = 0 + rand() % 100;
  37.             cout << b[i][j] << " ";
  38.         }
  39.         cout << endl;
  40.     }
  41.     cout << endl;
  42.     cout << endl;
  43.     int max_i = -1;
  44.     int k = 0;
  45.     for(int i=0; i<6; i++){
  46.         for (int j=0; j<4; j++){
  47.             if(b[k][j] > max_i){
  48.                 max_i = b[k][j];
  49.             }
  50.         }
  51.         cout <<"Максимальны эл " << k+1 << " строки " << max_i  << endl;
  52.         k++;
  53.         max_i = 0;
  54.     }
  55.     cout << endl;
  56.     int max_j = -1, k2 = 0;
  57.     while(k2!=4){
  58.     for(int i=0; i<6; i++){
  59.             if(b[i][k2] > max_j){
  60.                 max_j = b[i][k2];
  61.             }
  62.        
  63.     }
  64.     cout << "Максимальный эл " << k2+1 << " столбца " << max_j  << endl;;
  65.     k2++;
  66.     max_j = 0;
  67.     }
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment