救!为什么#9过不了啊?

P5707 【深基2.例12】上学迟到

sksla @ 2024-03-20 14:39:06

#include<stdio.h>
int main()
{
    float s,v,t,o;
    int x,y;
    scanf("%f %f",&s,&v);
    if(v==0||s==0)
        {printf("07:50");
            return 0;}
    o=1.0/6;
    t=8-s/v/60-o;
    if(t<0)
        t+=24;
    x=(int)t;
    y=(t-x)*60;
    printf("%02d:%02d",abs(x),abs(y));
    return 0;
}

by _TCR_ @ 2024-03-20 15:39:43

开双精度float→double


by sksla @ 2024-03-20 16:12:17

@TCR 解决了!感谢?太莫名其妙了


by _TCR_ @ 2024-03-20 19:12:57

@sksla c/c++遇到小数用最好double,精度问题


|