我在我的代码中发布了一个问题,其唯一的#include指令如下:
#include <bits/stdc++.h>
Run Code Online (Sandbox Code Playgroud)
我的老师告诉我这样做,但在评论部分,我被告知我不应该这样做.
为什么?
c++ portability c++-faq turbo-c++ implementation-defined-behavior
有没有办法让这个功能更优雅?我是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) c++ ×2
c++-faq ×1
implementation-defined-behavior ×1
max ×1
min ×1
portability ×1
turbo-c++ ×1