#include"stdio.h"
main()
{
int n,i,a,b;
double s=0;
scanf("%d",&n);
for (int i = 1; i < n; i++)
{
if (i % 3 == 0 && i % 7 == 0)
{
s = s + i;
}
}
s=sqrt(s);
printf("%d",s);
}
#include "stdio.h"
#include "math.h"
int main()
{
int n, i, a, b;
double s = 0;
scanf("%d", &n);
for (int i = 1; i < n; i++)
{
if (i % 3 == 0 && i % 7 == 0)
{
s = s + i;
}
}
s = sqrt(s);
printf("%lf", s);
return 0;
}
修改见注释,供参考:
#include <stdio.h>
#include <math.h> //修改
int main()
{
int n, i, a, b;
double s = 0;
scanf("%d", &n);
for (i = 1; i < n; i++) //修改
{
if (i % 3 == 0 && i % 7 == 0) //修改
{
s = s + i;
}
}
s = sqrt(s);
printf("%f", s); //修改
return 0;
}
因为你使用的sqrt这个函数, 这个函数来自于库 #include<math.h>, 把它加到最前面就能运行
有用请采纳