Advertisement
dllbridge

Untitled

Mar 2nd, 2025
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.49 KB | None | 0 0
  1.  
  2. #include  <stdlib.h>
  3. #include    <time.h>
  4. #include  <iostream>
  5. using namespace std;
  6.  
  7.  
  8.  
  9.  
  10. const int size = 20;
  11.  
  12.  
  13.  
  14.  
  15. void monitor(int *);
  16.  
  17. ////////////////////////////////////////////////////
  18. int main()
  19. {
  20.  
  21.  
  22.     int arr[size] = {10, 11, 22, 3, 44, 75, 86, 997, 8, 99,
  23.                       0,  1,  2,13,  4,  5,  6, 97, 28, 19};
  24.     srand(time(0));
  25.    
  26.     cout << "time(0) = " << time(0) << endl;
  27.  
  28.     int MinIndex = 0;
  29.     int MaxIndex = 0;
  30.    
  31.    
  32.  
  33.     for (int i = 0; i < size; ++i)
  34.     {
  35.         arr[i] = rand();
  36.        
  37.         if (arr[i] > arr[MaxIndex])     MaxIndex = i;
  38.         if (arr[i] < arr[MinIndex])     MinIndex = i;    
  39.     }
  40.    
  41.     monitor(arr);
  42.    
  43.     cout << "Max     "  << MaxIndex << endl;
  44.     cout << "minimum "  << MinIndex << endl;
  45.  
  46. return 0;
  47. }
  48.  
  49.  
  50.  
  51. ///////////////////////////////////////////////////////
  52. void monitor(int *p)
  53. {
  54.     for (int i = 0; i < size; ++i)
  55.     {
  56.         cout << p[i] << ", ";    
  57.     }    
  58.    
  59.     cout << endl;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. /*
  76. #include  <stdlib.h>
  77. #include    <time.h>
  78. #include  <iostream>
  79. using namespace std;
  80.  
  81.  
  82.  
  83.  
  84. const int size = 20;
  85.  
  86. int arr[size] = {10, 11, 22, 3, 44, 75, 86, 997, 8, 99,
  87.                       0,  1,  2,13,  4,  5,  6, 97, 28, 19};
  88.  
  89.  
  90. void monitor();
  91.  
  92. ////////////////////////////////////////////////////
  93. int main()
  94. {
  95.  
  96.     const int size = 20;
  97.    
  98.     srand(time(0));
  99.    
  100.     cout << "time(0) = " << time(0) << endl;
  101.  
  102.     int MinIndex = 0;
  103.     int MaxIndex = 0;
  104.    
  105.    
  106.  
  107.     for (int i = 0; i < size; ++i)
  108.     {
  109.         arr[i] = rand();
  110.        
  111.         if (arr[i] > arr[MaxIndex])     MaxIndex = i;
  112.         if (arr[i] < arr[MinIndex])     MinIndex = i;    
  113.     }
  114.    
  115.     monitor();
  116.    
  117.     cout << "Max     "  << MaxIndex << endl;
  118.     cout << "minimum "  << MinIndex << endl;
  119.  
  120. return 0;
  121. }
  122.  
  123.  
  124.  
  125. ///////////////////////////////////////////////////////
  126. void monitor()
  127. {
  128.     for (int i = 0; i < size; ++i)
  129.     {
  130.         cout << arr[i] << ", ";    
  131.     }    
  132.    
  133.     cout << endl;
  134. }
  135.  
  136. */
  137. /*
  138.  
  139. #include <iostream>
  140. using namespace std;
  141.  
  142.  
  143. ////////////////////////////////////////////////////
  144. int main()
  145. {
  146.  
  147.     const int size = 20;
  148.    
  149.     int arr[size] = {10, 11, 22, 3, 44, 75, 86, 997, 8, 99,
  150.                       0,  1,  2,13,  4,  5,  6, 97, 28, 19};
  151.     int MinIndex = 0;
  152.     int MaxIndex = 0;
  153.  
  154.     for (int i = 0; i < size; ++i)
  155.     {
  156.         if (arr[i] > arr[MaxIndex])     MaxIndex = i;
  157.         if (arr[i] < arr[MinIndex])     MinIndex = i;    
  158.     }
  159.    
  160.     cout << "Max     "  << MaxIndex << endl;
  161.     cout << "minimum "  << MinIndex << endl;
  162.  
  163. return 0;
  164. }
  165.  
  166.  
  167.  
  168. */
  169.  
  170.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement