+ 2
Finding Maximum number of an array in a read file
Hi guys, I have a homework which needs the maximum number of a class and the information of the classes are in a file. First I wrote the function of reading the file. Second I should write the function of finding the max number... and after these i have to write the main function. But I have a problem with writing the function of finding the max number Can you please help me with that?
4 Answers
+ 1
Can you share the code with your progress to the problem? That way, It will be easier to help.
+ 1
Yeah, But my entire code has 153 lines and itās hard to explain the whole... But to make my problem more clear I would say: I need an algorithm that gives me the maximum number of n numbers from an array in a file...
+ 1
You may use a built-in function, max_element(), from <algorithm>.
www.cplusplus.com/reference/algorithm/max_element
Eg :
int arr[6] = {1,2,48,2,1,22};
cout<<max_element(arr,arr+6);
// Prints 2, the position of the max element.
+ 1
Thanks, Iāll try it š