咋过不了啊,求指点

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

BOATCHUANGU @ 2024-09-21 20:29:57

#include<stdio.h>
int main()
{
    int s, v;
    scanf_s("%d %d", &s, &v);
    int t;
    t = (s + v - 1) / v + 10;
    int h, m;
    m =60- t % 60;
    if
        (t<=1440)
    {
        if (m != 60)
        {
            h = 7 - t / 60;
            printf("%2d:%2d", h, m);
        }
        else
        {
            h = 8 - t / 60;
            printf("%2d:00", h);
        }
    }
    return 0;
}

by laialaodi @ 2024-09-21 20:32:32

scanf_s 应该是给vs用的,OJ用不了


by laialaodi @ 2024-09-21 20:32:42

@BOATCHUANGU


by laialaodi @ 2024-09-21 20:34:47

还有

printf("%02d:%2d", h, m);

by BOATCHUANGU @ 2024-09-21 21:00:35

@laialaodi 又提交了,但是只有七十分。


by laialaodi @ 2024-09-21 21:03:40

@BOATCHUANGU 两处printf都改了吗


by BOATCHUANGU @ 2024-09-21 21:06:21

@laialaodi 对的,都改了

#include<stdio.h>
int main()
{
    int s, v;
    scanf("%d %d", &s, &v);
    int t;
    t = (s + v - 1) / v + 10;
    int h, m;//h:m
    m =60- t % 60;//求模取末尾

    if
        (t<=1440)
    {
        if (m != 60)
        {
            h = 7 - t / 60;
            printf("%02d:%02d", h, m);
        }
        else
        {
            h = 8 - t / 60;
            printf("%02d:00", h);
        }
    }
    return 0;
}

|