\\计算1/1-1/2+1/3...-1/100的和
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() { int x = 0; double sum = 0.0; int n = 1; for (x = 1; x <= 100; x++) { sum += n*1.0 / x; n = -n; } printf("1-1/2+1/3-...-1/100的值为:%lf", sum); return 0; }
标签:12,语言,int,代码,练习,main From: https://www.cnblogs.com/ayue6/p/17742481.html