JosepRivaille

P29094: Posició del màxim

May 23rd, 2015
2,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5.  
  6. int posicio_maxim(const vector<double>& v, int m) {
  7.     int max = 0;
  8.     double max_value = v[0];
  9.     for (int i = 1; i <= m; ++i) {
  10.         if (v[i] > max_value) {
  11.             max = i;
  12.             max_value = v[i];
  13.         }
  14.     }
  15.     return max;
  16. }
  17.  
  18. //JosepRivaille
Advertisement
Add Comment
Please, Sign In to add comment