unsigned maxIndex( const double a[], unsigned elements ); Return the index of th
ID: 3648287 • Letter: U
Question
unsigned maxIndex( const double a[], unsigned elements );Return the index of the largest element. If there is no largest element, complain and die. If there is a tie for the largest element, then return the largest element that has the larger subscript.
For example, if the array were {1.1, 3.3, 2.2, 3.3, -4.4}, then the function should return 3.
this far, i have
int main(){
unsigned c[] = {1.1, 3.3, 2.2, 3.3, -4.4};
cout<<"maxInd: "<<maxIndex(c, 5)<<endl;
}
unsigned maxIndex( const double a[], unsigned elements ){
int maxIndex = 0;
for( unsigned i = 0; i < elements; ++i )
if( a[maxIndex] < a[i] )
maxIndex = i;
return maxIndex;
}