How does the method min(a,b,c,d) affect the program by using method min(a,b) in it?
doubt
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
TomJack
14 October 2018, 15:29
if(min(a,b)<=c && min(a,b)<=d){
return min(a,b);
}else if(min(a,c)<=d && min(a,c)<=b){
return min(a,c);
}else if(min(a,d)<=b && min(a,d)<=c){
return min(a,d);
}else if(min(b,c)<=a && min(b,c)<=d){
return min(b,c);
}else if(min(b,d)<=a && min(b,d)<=c){
return min(b,d);
}else if(min(c,d)<=a && min(c,d)<=b){
return min(c,d);
}else{
return min(d,b);
}
0
asreen
14 October 2018, 13:27
Using the method min(a,b) in the method min(a,b,c,d) will make your program easierin the sense of applying the logic.In simple terms you are using the min(a,b) method to first get the min of first 2 integers and compare with the rest 2 integers rather than comparing the integers one by one with the rest other integers.Hope i was able to explain u correctly.
0
Ankush Rajput
8 October 2018, 14:45
Pass (a,b) to min(a,b) inside min(a,b,c,d) function. Then pass (c,d) to min(a,b) function. You'll get two values (min of a,b and min of c,d). Now again pass two values you got to min(a,b) function. You'll have your min value among a,b,c,d.
I hope this is what you were asking. If not, then please explain your question a bit more.
0