我想找到四個最低的數字,但這看起來有點奇怪,是不是有一個更聰明,更短的方法來做到這一點?比較4個變量來找到最低的C++
這就是我:
int findlowest(int one, int two, int three, int four) {
int output = one //as of now , we will be outputting one , except if we find a lower score.
if(output > two) { out = two;} // if output is proven to be bigger than two, two is our new output.
if(output > three){ output = three;} //same operation with three
if(output > four){ output = four;} // same operation with four
return output;
}
廢話你打我7秒,我的錯誤! – Marlon
是更好的平衡樹'std :: min(std :: min(a,b),std :: min(c,d));'? – osgx
@osgx:無功能差異。 –