首页 > 编程知识 正文

you will leave the world behind,middle of the nightoriginal mix

时间:2023-05-04 19:06:17 阅读:202293 作者:4428

C程序设计 (第四版) cqdzs 习题5.7 个人设计 习题 5.7 求k=1,k到100的相加和,k平方到50的相加和,1/k到10的相加和。

∑k=1100k+∑k=150k2+∑k=1101k

代码块

#include <stdio.h>#include <math.h>int main(){ double k, s1, s2, s3; for (k=1, s1=0; k<=100; s1+=k, k++); for (k=1, s2=0; k<=50; s2+=pow(k, 2), k++); for (k=1, s3=0; k<=10; s3+=1/k, k++); printf("sum=%.2lfn", s1+s2+s3); return 0;}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。