标签:刷题 turn blog sum logs panel amp get printf
100 50 10
47977.93
1 #include <stdio.h> 2 3 int get_sum (int n); 4 int get_square_sum (int n); 5 float get_reciprocal_sum (int n); 6 7 int main(){ 8 9 int a,b,c; 10 float SN = 0; 11 12 scanf("%d %d %d",&a,&b,&c); 13 SN = get_sum(a) + get_square_sum(b) + get_reciprocal_sum(c); 14 15 printf("%.2f",SN); 16 return 0; 17 } 18 19 int get_sum (int n) 20 { 21 int i,sum = 0; 22 for (i = 1;i <= n;i ++) 23 { 24 sum += i; 25 } 26 return sum; 27 } 28 29 int get_square_sum (int n) 30 { 31 int i,sum = 0; 32 for (i = 1;i <= n;i ++) 33 { 34 sum += i * i; 35 } 36 return sum; 37 } 38 39 float get_reciprocal_sum (int n) 40 { 41 int i; 42 float sum = 0; 43 for (i = 1;i <= n;i ++) 44 { 45 sum += 1.0 / i; 46 } 47 return sum; 48 }
标签:刷题 turn blog sum logs panel amp get printf
原文地址:http://www.cnblogs.com/xiangxyq/p/7803482.html