C语言程序编程设计题
论文问答
1
-
#include <stdio.h> #include <string.h> #include <stdlib.h> float fun(float num){ int n = 1; float t=1, result; while(fabs(t)>=num){ result = result + t; n=n+1; t=1/pow(n,2); } return result; } int main(){ float n1,n2; n1=0.000001; n2=fun(n1); printf("%6.6f",n2); return 0; }
-
#include <stdio.h> int main() { float ex = 0.000001; float sum = 0.0; float t =1; int i = 1; while(t > ex) { t = 1.0/(i*i); sum += t; i++; } printf("和=%f\n",sum); return 0; }
发表回复