Trouble finding highest/lowest element in array C++ -
I am very new to C ++, only had experience in C #, Python and JS, so bear with me !
I am taking the user input on 5 points and storing it in an array. I pass the array and evaluate the digits in the array to find the lowest value and the highest value. I have to leave those two, then the other 3 values should have an average address. My problem is, I can not find the highest / lowest value I have the argument () and find the highest () but to test it I have put the same argument in the main () to see that What work he has, and his work is not. Can someone guide me to find the highest / lowest values in the array? Thanks!
#include "stdafx.h" #include & lt; Iostream & gt; # Include & lt; Semith & gt; # Include & lt; Iomanip & gt; # Include & lt; Algorithm & gt; using namespace std; Zero getJudgeData (double score) {cin> & Gt; Score; If (score> 10 || score & lt; 0) {cout & lt; & Lt; "Invalid score, please enter again." & Lt; & Lt; Endl; Cin & gt; & Gt; Score; } And {cout & lt; & Lt; "Thank you." & Lt; & Lt; Endl; }} Double Search Loovist (double score []) {double low score = * min_element (score, score + 5); Return low score; } Dual search highest (double score []) {double high score = * max_sement (score, score + 5); Return high score; } Double Callscore (double score []) {Double final score; Double zodiac = 0; Double Ncore [3] = {}; Double low score = searchlog (score); Double highscore = highest (score); Int j = 0; (Int i = 0; i gt; in_avail ()); Cout & lt; & Lt; "To exit the program, just hit 'Enter' key:"; Cin.get (); Return 0; }
The reason is that getJudgeData takes
As a result from the double score
value, the entries by the end user are restricted to the getJudgeData function;
Jokescore [i]
variable which you go through the function remains unchanged.
Add the ampersand to fix this problem:
zero getJudgeData (double & score) {...}
< P> Now the parameter is passed from the reference, getJudgeData lets modify it.
Comments
Post a Comment