除了测试点9全WA,但是看不出来问题在哪

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

zhengfly @ 2024-10-09 16:57:36

#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int s,v,h,m;
    scanf("%d%d",&s,&v);
    int t=480-10-s/v;
    if (t>=0)
    {
        m=t%60;
        h=t/60;

    }
    else
    {
        t=t%(24*60)+24*60;
        m=t%60;
        h=t/60;
    }
    printf("%02d:%02d",h,m);
    return 0;
}

by zhengfly @ 2024-10-09 19:06:08

改了一下,WA8和10,真不知道错哪了,求大佬救救

#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int s,v,h,m;
    scanf("%d%d",&s,&v);
    int t=480-10-(float)s/v;
    if (t>=0)
    {
        m=t%60;
        h=t/60;

    }
    else
    {
        t=t%(24*60)+24*60;
        m=t%60;
        h=t/60;
    }

    printf("%02d:%02d",h,m);
    return 0;
}

@zhengfly


|