求救大佬们,到底哪里出错了

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

jilok @ 2024-08-26 06:47:31

include <stdio.h>

int main() {

```c

include <stdio.h>

int main() { int s, v; scanf("%d %d", &s, &v); if (s < 1 && v>10000 && v >= 0) {

}
else
{
    int i = 480 - 10 - s / v;
    if (i == 0) {
        printf("00:00");
    }
    else if (i > 0) {
        int q = s / v;
        int w = s % v;
        if (w > 0) {
            q++;
        }
        int e = 480 - q - 10;
        int h = e / 60;
        int m = e % 60;
        if (h < 10) {
            printf("0%d:%d",h,m);
        }
        else
        {
            printf("%d:%d", h, m);
        }
    }
    else if (i < 0 && i >= -960) {
        int r = s / v;
        int t = s % v;
        if (t > 0) {
            r++;
        }
        int y = r - 480 + 10;
        int H = 23 - y / 60;
        int M = 60 - y % 60;
        if (H < 10) {
            printf("0%d:%d", H, M);
        }
        else
        {
            printf("%d:%d", H, M);
        }
    }
    else
    {

    }
}
return 0;
}

int s, v;
    scanf("%d %d", &s, &v);
    if (s < 1 && v>10000 && v >= 0) {

    }
    else
    {
        int i = 480 - 10 - s / v;
        if (i == 0) {
            printf("00:00");
        }
        else if (i > 0) {
            int q = s / v;
            int w = s % v;
            if (w > 0) {
                q++;
            }
            int e = 480 - q - 10;
            int h = e / 60;
            int m = e % 60;
            if (h < 10) {
                printf("0%d:%d",h,m);
            }
            else
            {
                printf("%d:%d", h, m);
            }
        }
        else if (i < 0 && i >= -960) {
            int r = s / v;
            int t = s % v;
            if (t > 0) {
                r++;
            }
            int y = r - 480 + 10;
            int H = 23 - y / 60;
            int M = 60 - y % 60;
            if (H < 10) {
                printf("0%d:%d", H, M);
            }
            else
            {
                printf("%d:%d", H, M);
            }
        }
        else
        {

        }
    }
    return 0;
    }

by Jason_Teng @ 2024-08-26 08:19:46

这题忒简单了!,你当7:50到校,再写:

int u = s / v + (s / v * v < v ? 1 : 0) + 10;
int h = u / 60 + (u % 60 != 0 ? 1 : 0);
int m = 60 - u % 60;
if(m == 60)
    m = 0;
printf("0%d:%d",h,m);

就行啦


by Jason_Teng @ 2024-08-26 08:20:55

还有,新手蒟蒻应用标配cout


by Jason_Teng @ 2024-08-26 08:21:35

@a3481171079


by Jason_Teng @ 2024-08-26 08:22:21

其实我也用cout


by Jason_Teng @ 2024-08-26 08:30:43

条件表达式详解


by jilok @ 2024-08-26 17:29:09

@shabiJason 大佬,我还没学cout


by jilok @ 2024-08-26 17:29:29

@shabiJason 感谢感谢


by Jason_Teng @ 2024-08-26 20:23:16

壶关? @a3481171079


by Jason_Teng @ 2024-08-26 20:24:51

@a3481171079 ,cout详解明天好


by jilok @ 2024-08-28 01:19:11

@shabiJason 好的


| 下一页