#include <stdio.h> #include <stdlib.h> int main() { int sign = 1; double deno = 2.0; double sum = 1.0; double result = 0; while (deno <= 100) { sign = (-1)*sign; result = sign / deno; sum = sum + result; deno = deno + 1; } printf("%f\n", sum); system("pause"); return 0; }
计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值C语言代码
原文地址:http://10919090.blog.51cto.com/10909090/1719851