35657

Untitled

Nov 16th, 2023
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9.     const int size = 5;
  10.     int arr[size]{ 23,-11,9,-18, -25 };
  11.  
  12.     int min = arr[0];
  13.     int max = arr[0];
  14.  
  15.     for (int i = 0; i < size; i++) {
  16.         if (arr[i] < min) {
  17.             min = arr[i];
  18.         }
  19.         if (arr[i] > max) {
  20.             max = arr[i];
  21.         }
  22.     }
  23.     cout << "max = " << max << endl;
  24.     cout << "min = " << min << endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment