0分,写了一个下午,求助

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

inkunit @ 2023-11-27 17:39:42

#include <stdio.h>
int main()
{
    int s,v;
    int sum = 60;
    int sum1 = 8;
    int flag = 0;
    scanf("%d %d",&s,&v);
    int t = s / v+10;
    int t1 = t/60;
    if(t<=60)//特判总分钟小于60min,如果不能整除,就要让时间再减少一分钟
    {
        if(s%v!=0)
        sum-=(t+1);
        else
        sum-=t;
    }
    else//主要判断小时和24H之间的关系
    {
    destination:
        if(t1<8)//小于八个小时,就好办了,直接8-总小时数
        {
            sum1-=t1;
        }
        else//大于八个小时就再判是不是大于24h,不是的话就拿24-(8-h)
        {
            if(t1<24)
            {
                if(flag==0)
                {
                    t1=32-t1;
                    sum1 = t1;
                }
                else
                sum1 = 31-t1;
            }
            else//非常大了这个数字=-=所以还是取余24h,也只有一次。
            {
                t1=t1%24;
                flag = 1;
                goto destination;
            }
        }
        if(s%v==0)
        sum-=t%60;
        else
        sum-=(t+1)%60;
    }
    if(sum==60&&sum1<23)//加那么多特判了怎么还不给过啊=-=
    printf("%02d:00",sum1+1);
    else if(sum!=60&&sum1==24)
    printf("00:%02d",sum);
    else if(sum==60&&sum1==23)
    printf("00:00");
    else if(sum==60&&sum1==24)
    printf("01:00");
    else if(flag==0)
    printf("%02d:%02d",sum1,sum);
    else if(flag==1&&sum!=60)
    printf("%02d:%02d",sum1-1,sum);
    else if(flag==1&&sum==60&&sum1<23)
    {
        printf("%02d:00",sum1-1);
    }
    else if(flag==1&&sum==60&&sum1==23)
    {
        printf("00:00");
    }
    else if(flag==1&&sum==60&&sum1==24)
    {
        printf("01:00");
    }
    return 0;
}

by bcbgszyzh @ 2023-11-28 20:51:37

...... @inkunit


by inkunit @ 2023-11-28 22:29:05

@bcbgszyzh QUQ


by bcbgszyzh @ 2023-11-29 10:21:14

太啰嗦 @inkunit


|