寻找在num范围内,能被多个小数整除的有理数

#include 
#include 

int main () {
	double num = 2.0;
	std::vector<double> decimals = {0.05, 0.10, 0.15};
	for (double i = num; i > 0.; i -= 0.01) {
      double num_decider = -1;
      for (int index = 0; index < decimals.size(); ++index) {
        const double result = std::abs(std::remainder(i, decimals[index]));
        num_decider = num_decider + result;
        if (result > math::epsilon) {
          break;
        }
      }
      if (num_decider + 1 < math::kEpsilon) {
         cout<< " actual num: " << i;
        break;
      }
    }
}

你可能感兴趣的:(算法,算法,c++)