¶
료 , 100 ;;
code ¶
~cpp /** Chapter 1.2 (2)Problem Solving programmed by eternalbleu (youngchang park, 2001 1612) Date: 2005 09 10 **/ #include <iostream> // 러리를 매 #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 #define PARAM_X 2.0 #define COEFFICIENTS {1, 2, 3, 4, 5, 6, 7} double horner_func(double, double*, int); int max_exponentials = 0; int main () { double x_param = PARAM_X; // index 를 배 . double coefficient [] = COEFFICIENTS; max_exponentials = sizeof(coefficient) / sizeof(double); std::cout<<horner_func(x_param, coefficient, 0)<<std::endl; return EXIT_SUCCESS; } /** horner_func . @param x_param 미 . @param coefficient 배. @param exponential 미 . @return + **/ double horner_func(double x_param, double* coefficient, int exponential) { // Recursion Termination Condition if (exponential == max_exponentials-1) return coefficient[exponential]; // General Recursion Call return horner_func(x_param, coefficient, exponential+1)*x_param + coefficient[exponential]; }