有没有办法让这个功能更优雅?我是C++的新手,我不知道是否有更标准化的方法来做到这一点.这可以变成一个循环,所以变量的数量不受我的代码限制吗?
float smallest(int x, int y, int z) {
int smallest = 99999;
if (x < smallest)
smallest=x;
if (y < smallest)
smallest=y;
if(z < smallest)
smallest=z;
return smallest;
}
Run Code Online (Sandbox Code Playgroud)