主函数main: // multinomial.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "stdlib.h" #include "string.h" #include "E:/C_Data_Structures/Linear_List/multinomial/Horner.h" int _tmain(int argc, _TCHAR* argv[]) { _Horner(); system("PAUSE"); return 0; } 头文件Horner.h: #ifndef HORNER_H_INCLUDED #define HORNER_H_INCLUDED void Create(double *&a,int n) { a = (double*)calloc(n,sizeof(double)); if(!a) { fprintf(stderr,"Insufficient memory."); exit(EXIT_FAILURE); } for(--n;n >= 0;--n) { scanf("%lf",&a[n]); } } void Test_Horner(double *&a,int n,double &A) { double x; scanf("%lf",&x); while(n) { A = A*x + a[--n]; } //printf("%.2lf",A); free(a); a = NULL; } void _Horner() { int n; scanf("%d",&n); double *a = NULL,A = 0; Create(a,n); Test_Horner(a,n,A); printf("%.2lf",A); } #endif //测试数据 /* 3 2.11 3.21 4.15 1.11 */