c语言 70分求助

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

wincking @ 2024-12-13 22:26:48

#include<stdio.h>
#include<math.h>
int main(){
    int s,v,t;
    scanf("%d %d",&s,&v);
    t=ceil((double)s/v);
    int h1=t/60,m1=t%60;
    int h=7,m=50;
    if(m-m1<0){
        h--;
        m+=60;
    }
    h=h-h1;m=m-m1;
    if(m<10){
        printf("0%d:0%d",h,m);
    }else{
        printf("0%d:%d",h,m);
    }
    return 0;
}

by LionBlaze @ 2024-12-13 22:33:32

@wincking 你确定时的首位一定是 0?


by wincking @ 2024-12-14 15:23:15

@LionBlaze 我靠 谢谢佬 我还以为是时间不会超过00:00.


|