Advertisement
Garey

krisi

Nov 28th, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7.     int A[10], max, min;
  8.  
  9.     for (size_t i = 0; i < 10; i++) {
  10.         cout << "A[" << i << "]: ";
  11.         cin >> A[i];
  12.     }
  13.  
  14.     max = min = A[0];
  15.  
  16.     for (size_t i = 0; i < 10; i++) {
  17.  
  18.         if (min > A[i])
  19.             min = A[i];
  20.         else if (max < A[i])
  21.             max = A[i];
  22.  
  23.         cout << "A[" << i << "]: " << A[i] << endl;
  24.     }
  25.  
  26.     cout << "Min element: " << min << " | Max Element: " << max << " | Difference between them: " << (max - min) << endl;
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement