fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. // Declaring functions
  7.  
  8. int trova_massimo(int N, vector<int> V) {
  9. int massimo = 0;
  10. for (int i = 0; i < N; i++) {
  11. if (V[i] > massimo) {
  12. massimo = V[i];
  13. }
  14. }
  15. return massimo;
  16. }
  17.  
  18. int main() {
  19. ios::sync_with_stdio(false);
  20.  
  21. // Uncomment the following lines if you want to read/write from files
  22. // ifstream cin("input.txt");
  23. // ofstream cout("output.txt");
  24.  
  25. int N;
  26. cin >> N;
  27.  
  28. vector<int> V(N);
  29. for(int i = 0; i < N; i++) {
  30. cin >> V[i];
  31. }
  32.  
  33. cout << trova_massimo(N, move(V)) << endl;
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 5284KB
stdin
5
3 9 0 6 5
stdout
9