能帮忙看一下这个C语言的8,9,10为什么不行吗。代码如下。
查看原帖
能帮忙看一下这个C语言的8,9,10为什么不行吗。代码如下。
1647577
WulongTZB楼主2025/1/20 16:28
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
    int s, v, spendhour = 0, totalminute = 0, spendminute,minute=0, roalhour = 8, starthour = 0,roalminute=60;
    //spendhour为花费的小时,roalhour为目标小时到,totalhour为走到学校和整理垃圾的总时间,starthour为出发时的小时,minute为出发时的分钟数。
    //spendminute为花费的分钟,roalminute为目标分钟到。
    scanf("%d %d", &s, &v);
    totalminute = s / v + 10;
    if (s / (double)v != 0)
        totalminute += 1;
    spendhour = totalminute / 60;
    spendminute = totalminute % 60;
    if (spendhour > roalhour && spendhour < 24) {
        starthour = 24 - (spendhour - roalhour);
    }
    else
    {
        starthour = roalhour - spendhour-1;
    }
    if (spendhour >= 24)
    {
        printf("false");
        return 0;
    }
    minute = roalminute - spendminute;
    if (starthour < 10)
    {
        printf("%02d:%02d\n", starthour, minute);
    }
    else
    {
        printf("%d:%2d\n", starthour, minute);
    }
    return 0;
}
2025/1/20 16:28
加载中...