求解:编程计算下列函数值 第六题
程序代码:
#include<stdio.h> #include<math.h> double f(int x,int y); int s(int n); int p(int i); int i,n,j; int main(void) { int x,y; printf("input x and y:\n"); scanf("%d%d",&x,&y); printf("\nf(x,y)=%lf\n",f(x,y)); } double f(int x,int y) { return double(s(x))/double(s(y)); } int s(int n) { int sum=0; for(i=1;i<=n;i++) { sum+=p(n); } return sum; } int p(int i) { int acc=1; for(j=1;j<=i;j++) { acc*=j; } return acc; }