相关疑难解决方法(0)

我为什么不#include <bits/stdc ++.h>?

我在我的代码中发布了一个问题,其唯一的#include指令如下:

#include <bits/stdc++.h>
Run Code Online (Sandbox Code Playgroud)

我的老师告诉我这样做,但在评论部分,我被告知我不应该这样做.

为什么?

c++ portability c++-faq turbo-c++ implementation-defined-behavior

215
推荐指数
6
解决办法
2万
查看次数

找到C++中3个数字中最小的数字

有没有办法让这个功能更优雅?我是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++ max min

28
推荐指数
6
解决办法
8万
查看次数