Sanlover

Untitled

Dec 4th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int N;
  7. int tmp, max, min;
  8.  
  9. cout << "Enter the amount of numbers(N) = ";
  10. cin >> N;
  11.  
  12. cout << "Enter the numbers:" << endl;
  13. cin >> tmp;
  14. max = min = tmp;
  15.  
  16. for (int i = 1; i < N; i++)
  17. {
  18. cin >> tmp;
  19. if (tmp > max)
  20. max = tmp;
  21. if (tmp < min)
  22. min = tmp;
  23. }
  24.  
  25. cout << "Summary of max and min elements equals = " << min + max << endl;
  26. return 0;
  27. }
Add Comment
Please, Sign In to add comment