3145779708nb @ 2022-10-21 00:29:05
int main()
{
int a,b,c,i,m;
int s=0,x=0;
float s1,m1;
scanf("%d %d",&a,&b);
c=a/b;
for (int i = b; i <= a; i += b)
s += i;
s1=s/c;
printf("%.1f",s1);
for(i=1;i<=a;i++)
{
x=x+i;
}
m=x-s;
m1=m/(a-c);
printf("%.1f",m1);
return 0;
}
by WZWZWZWY @ 2022-10-21 08:41:18
m1=m/(a-c);
这一行的结果也会是整数。应该将被除数或者除数乘1.0
这一行s1=s/c;
同理@3145779708nb
by Arrosw @ 2022-10-23 10:45:02
@3145779708nb 把float改成double