SHARE
TWEET

Untitled

a guest Dec 10th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int i, a, b;
  7.  
  8. int main()
  9. {
  10.     int massiv[10];
  11.     int max = 0;
  12.     int min = 50;
  13.     int a = 0;
  14.     int b = 0;
  15.  
  16.     srand(time(NULL));
  17.  
  18.     for (int i = 0; i < 10; i++)
  19.     {
  20.         massiv[i] =1 + rand() % 40;
  21.         cout << massiv[i] << " ";
  22.     }
  23.     cout << endl;
  24.    
  25.     for (int i = 0; i < 10; i++)
  26.     {
  27.         if (massiv[i] > max)
  28.         {
  29.             max = massiv[i];
  30.             a = i+1;
  31.         }
  32.     }
  33.    
  34.     for (int i = 0; i < 10; i++)
  35.     {
  36.         if (massiv[i] < min)
  37.         {
  38.             min = massiv[i];
  39.             b = i+1;
  40.         }
  41.     }
  42.    
  43.     cout << "Max znachenie: " << max << endl << "Nomer ellementa: " << a << endl;
  44.     cout << "Min znachenie: " << min << endl << "Nomer ellementa: " << b << endl;
  45.     system("pause");
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top