c语言三个求和数列相加 为什么得数小数全是0 求大神!!
#include<stdio.h>#include<stdlib.h>
int main()
{
double sum1 = 0; int sum2 = 0; double sum3 = 0, sum;
for (int i = 1; i<=100; i++)
{
sum1 = sum1 + i;
}
for (int j = 1; j<=20; j++)
{
sum2 = sum2 + j*j;
}
for (int k = 1; k<=200; k++)
{
sum3 = sum3 + 1 / k;
}
printf("sum=%10.6lf", sum = sum1 + (double)sum2 + sum3);
system("pause");
return 0;
}