/* 计算:1+2+3+.....n+1*1+2*2+..m*m+1/1+1/2+...1/k; */ #include <stdio.h> double add(int n){ double s1=0.0; for(int i=1;i<=n;i++){ s1+=i; } return s1; } double chen(int m){ double s2=0.0; for(int i=i;i<=m;i++){ s2+=i*i; } return s2; } double chu(int k){ double s3=0.0; for(int i=0;i<=k;i++){ s3+=1.0/i; } return s3; } int main(){ int n,m,k; double s1,s2,s3,s4; scanf("%d%d%d",&n,&m,&k); s1=add(n); s2=chen(m); s3=chu(k); s4=s1+s2+s3; printf("%lf %lf %lf %lf\n",s4,s1,s2,s3); return 0; }
收录于文章《885程序设计考点狂背总目录中》