fork download
  1. // Level 1 - Homework 1 - Question E - Solution 2.
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int N = 0;
  9. int X = 0;
  10. cin >> N >> X;
  11. int Max = X;
  12.  
  13. for(int i = 1; i < N; ++i)
  14. {
  15. cin >> X;
  16.  
  17. if(X > Max)
  18. Max = X;
  19. }
  20.  
  21. cout << Max << endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 5308KB
stdin
5
1 8 5 7 5
stdout
8