Advertisement
Xsufu

Untitled

Dec 19th, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <ctime> //библиотека для time
  4. using namespace std;
  5.  
  6. int main(){
  7.     setlocale(LC_ALL,"RUSSIAN");
  8.     int max = 0, min = 41;
  9.     const int N = 10;
  10.     int mass[N];
  11.    
  12.     srand(time(NULL));
  13.    
  14.     for (int i = 0; i<N; i++){
  15.         mass[i] = 1+rand()%40;
  16.         cout << mass[i] << " ";
  17.     }
  18.  
  19.     for (int i = 0; i<N; i++) {
  20.         if (mass[i]<min) {
  21.             min = mass[i];
  22.         }
  23.         if (mass[i]>max) {
  24.             max = mass[i];
  25.         }
  26.     }
  27.  
  28.     cout << "\n" << "Максимум: " << max << endl;
  29.     cout << "Минимум " << min << endl;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement