解题思路://见注释
注意事项:
参考代码:
#include<stdio.h>
#include<math.h>
int main()
{
int num_sum = 0, square_sum = 0;
double inverse_sum = 0;
int a = 0, b = 0, c = 0;
double Sum = 0;
scanf("%d %d %d", &a, &b, &c);
for (int i = 1; i <= a; i++)
{
num_sum = num_sum + i;
}
for (int i = 1; i <= b; i++)
{
square_sum = square_sum + pow(i,2);//pow包含在头文件#include<math.h>中,pow(x,y)表示x的y次方
}
for (int i = 1; i <= c; i++)
{
inverse_sum = inverse_sum + (1.0/i);
}
Sum = num_sum + square_sum + inverse_sum;
printf("%.2lf", Sum);
return 0;
}
0.0分
0 人评分