c语言编程求数列的1/1-1/3+1/5-1/7+1/9……前20项的累计和?

日期:2020-05-04 18:51:13 人气:1

c语言编程求数列的1/1-1/3+1/5-1/7+1/9……前20项的累计和?

#include int main() { int num = 1, sign = 1, term = 1; double sum = 1.00; while (num <= 20) { sign = -sign; term = term + 2; sum = sum + ( (double) sign / term); num++; } printf("前20项和=%
    A+
热门评论