Position of the maximum P29094


Statement
 

pdf   zip   main.cc   main.c   main.java   main.py

html

Write a function that returns the position of the maximum element of v[0..m]. If there is a tie, the smaller position must be returned.

Precondition

0 ≤ m < size of v.

Interface

C++
int position_maximum(const vector<double>& v, int m);
C
int position_maximum(double* v, int m);
Java
public static int positionMaximum(double[] v, int m);
Python
position_maximum(v, m) # returns int
 
position_maximum(v: list, m: int) -> int

Observation You only need to submit the required procedure; your main program will be ignored.

Information
Author
Salvador Roura
Language
English
Translator
Carlos Molina
Original language
Catalan
Other languages
Catalan
Official solutions
C C++ Java Python
User solutions
C C++ Python