0

A problem with thinking.

Can you guys explain to me how to make a programme that after giving "k" values into an array, prints the biggest number from them? Please guys, I am helpless :(

7th Dec 2016, 7:12 AM
Krzysztof Król
Krzysztof Król - avatar
5 Réponses
+ 9
I have a problem with thinking :c
7th Dec 2016, 7:45 AM
Ahri Fox
Ahri Fox - avatar
+ 5
do it while you giving the input. 1) define a max variable 2) have a special case for the first input so it become the current max 3) for every new input, compare to the current max and if it is bigger, make it the new max 4) ....??? 5) profit!!!
7th Dec 2016, 7:35 AM
Burey
Burey - avatar
+ 4
check in my codes for 'Find max value in array' or click here: https://code.sololearn.com/cS9e7F6NfM58/#cs make sure to press 'return' after each value (put all values beforehand) and -1 should be the last value (just special value to indicate end of array and can be changed in the program) like this: input: 5 3 75 388 9 211 -1
7th Dec 2016, 8:18 AM
Burey
Burey - avatar
+ 1
In python there is a max() function, that accepts list as an argument, and returns the maximum value. I haven't done C++, but in C there is no such library function available on array. You can write a user defined function. Try yourself Let me know if you're unable to.
7th Dec 2016, 7:23 AM
Rishi Anand
Rishi Anand - avatar
0
Thanks a lot guys! :)
7th Dec 2016, 5:27 PM
Krzysztof Król
Krzysztof Król - avatar