这个B类数为什么不对呢

P5719 【深基4.例3】分类平均

My3211215504 @ 2024-03-11 21:46:35

#include<stdio.h>
int main(){
    int n,k,num=0,x=0,m=0,sum=0;
    float a1,a2;
    scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
{
    if(i%k==0)
    {
        x++;
        num+=i;     
    }
    else m++;
    sum+=i;

}
a1=num*1.0/x;
a2=sum*1.0/m;
printf("%.1f %.1f",a1,a2);
return 0;
}

by guang_zi_guei_ji @ 2024-04-27 19:58:13

else没加花括号


by llhhss @ 2024-09-05 21:27:05

else没有花括号


|