0
How to find the position of minimum and maximum value in an array
If anyone knows to find about the position of an array..say me friends..
24 Antworten
+ 1
Bebida Roja You have to read answers because its all writed... Futhermore when someone ask for code without post some try its very probable that he/she want make own assignements from othets... Luckly Dhiviya Thirumavalavan have admitted this and i trying to come to solution step by step (for make he leatn something) but all its unuseful if someone make his assignemer for he
0
in algorithm header, std::find and std::find_if
0
Calviղ
I need in C language
0
Bebida Roja
I can"t get your point friend
0
loop on array comparing items with current then return it
for item in array
if item is first or item its less than currmin
currmin = item
return currmin
0
If you don"t mine can you say me elaborately
0
KrOW
I mean I am asking the C code to find position
0
Here a code I wrote some time ago that does exactly this. But its C++.
https://code.sololearn.com/c9g908Z1Hh9K/?ref=app
0
Dhiviya Thirumavalavan Sorry but i dont post code if user dont post his code.... I dont know you case but in general dont make other users assignements
0
KrOW
ok ok
0
Dhiviya Thirumavalavan This make me think that your is an assignement, right?
0
KrOW
yaa its kk..
I need to think on own..
There is nothing problem in it
0
Dhiviya Thirumavalavan Try always to find a solution yourself, in this way you will learn while dont happen if someone make it for you.... Try to simplify your problem... At example, can you give me a solution to find a min/max from 2 values?
0
Here another code ive just made.
It could easily be edited to create a Min class.
https://code.sololearn.com/ccbO2j9ePEF0/?ref=app
0
Bebida Roja You have understanded that his is an assignement? You know that this assignement is made for understand basic loop comprension? You have understanded that he need code it in C?
P.S. Wow, create 3 template classes only for get max from some numbers... Practically really unuseful but good for experiment with template
0
Useful in performance critical code as this gets calculated at compile time. And I dont think the teacher will accept this as a solution to the asignment. I wouldnt if he doesnt know what he is doing. And I didnt know it was needed in C :S
0
Bebida Roja Then why you post these codes if he cannot understand they?
0
It does what he asked, and fast.
0
Also, the last specialization is not needed. It is just there because consistence, to be able to get the maximum of one number, but it is trivial.