发布网友 发布时间:2022-04-24 04:44
共2个回答
热心网友 时间:2023-10-29 08:25
#include <stdio.h>
double fun(int n)
{
int i;
double sum = 0.0;
/**********found**********/
for (i = 1; i <= n; i++)
/**********found**********/
if (i % 3 == 0 || i % 7 == 0)
/**********found**********/
sum += 1. / i;
return sum;
}
void main()
{
int n;
double s;
printf("\nInput n: ");
scanf("%d", &n);
s = fun(n);
printf("\n\ns=%lf\n", s);
}
热心网友 时间:2023-10-29 08:26
1 i<=n
2 ||
3 1
热心网友 时间:2023-10-29 08:25
#include <stdio.h>
double fun(int n)
{
int i;
double sum = 0.0;
/**********found**********/
for (i = 1; i <= n; i++)
/**********found**********/
if (i % 3 == 0 || i % 7 == 0)
/**********found**********/
sum += 1. / i;
return sum;
}
void main()
{
int n;
double s;
printf("\nInput n: ");
scanf("%d", &n);
s = fun(n);
printf("\n\ns=%lf\n", s);
}
热心网友 时间:2023-10-29 08:26
1 i<=n
2 ||
3 1
热心网友 时间:2023-10-29 08:26
#include <stdio.h>
double fun(int n)
{
int i;
double sum = 0.0;
/**********found**********/
for (i = 1; i <= n; i++)
/**********found**********/
if (i % 3 == 0 || i % 7 == 0)
/**********found**********/
sum += 1. / i;
return sum;
}
void main()
{
int n;
double s;
printf("\nInput n: ");
scanf("%d", &n);
s = fun(n);
printf("\n\ns=%lf\n", s);
}
热心网友 时间:2023-10-29 08:26
1 i<=n
2 ||
3 1