zzulioj:1015时间间隔

思路:不够减,就从高位借

#include <stdio.h>

int main() {
    
    
    int hour1,hour2,min1,min2,second1,second2;
    scanf("%d:%d:%d",&hour1,&min1,&second1);
    scanf("%d:%d:%d",&hour2,&min2,&second2);
    int ih=hour2-hour1;
    int im=min2-min1;
    int is=second2-second1;
    if(im<0){
    
    
        im=60+im;
        ih--;
    }
    if(is<0){
    
    
        is=60+is;
        im--;
    }
    int time;
    time=3600*ih+60*im+is;
    printf("%d",time);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_46225406/article/details/117450904