1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| #include <stdio.h> #include <stdlib.h> #define N 10
int QiuMi(int x,int a) { return a*x; } void PrintPn(int *a,int n,int x) { int Pn=0,count=1; for(int i=1;i<n;i++) { Pn+=(a[i]*QiuMi(x,count)); count=QiuMi(x,count); } Pn+=a[0]; printf("Pn(%d)=%d\n",x,Pn); } int main() { int a[N],x; printf("Please input %d numbers: \n",N); for(int i=0;i<N;i++) { scanf("%d",&a[i]); } printf("Please input X0: \n"); scanf("%d",&x); PrintPn(a,N,x); system("pause"); return 0; }
|