當前位置:編程學習大全網 - 電腦編程 - c語言(計算機2級上機題目)

c語言(計算機2級上機題目)

/*

Input eps : 0.0005

eps = 0.000500, PI/2 = 1.570553

Press any key to continue

*/

#include <stdio.h>

#include <math.h>

double fun(double eps) {

double m = 1.0,n = 1.0,t = 1.0,sum = 1.0;

int i;

for(i = 1;t >= eps; ++i) {

m *= i;

n *= 2 * i + 1;

t = m/n;

sum += t;

}

return sum;

}

int main() {

double x;

// void NONO();

printf("Input eps : ");

scanf("%lf",&x);

printf("\neps = %lf, PI/2 = %lf\n", x, fun(x));

// NONO();

return 0;

}

  • 上一篇:我問喜歡的男生(計算機很6)很簡單的編程問題,他會覺得我太菜,從而輕視我嗎
  • 下一篇:小豬佩奇像素畫怎麽畫
  • copyright 2024編程學習大全網