编辑: huangshuowei01 | 2014-09-06 |
3、面向过程的C实现 这是 csdn 算法论坛前版主海星的代码,程序非常简练、精致: #include #include #include using namespace std;
const double PRECISION = 1E-6;
const int COUNT_OF_NUMBER = 4;
const int NUMBER_TO_BE_CAL = 24;
double number[COUNT_OF_NUMBER];
string expression[COUNT_OF_NUMBER];
bool Search(int n) { if (n == 1) { if ( fabs(number[0] - NUMBER_TO_BE_CAL) < PRECISION ) { cout x;
number[i] = x;
itoa(x, buffer, 10);
expression[i] = buffer;
} if ( Search(COUNT_OF_NUMBER) ) { cout