C语言80分求助,卡4,7wa找不到错误

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

MZH666 @ 2024-07-27 22:55:24

#include<stdio.h>
int main(){
    int s,v,hos,min,hos1,min1;
    scanf("%d %d",&s,&v);
    min=s/v;
    hos=0;
    if(s%v!=0){
        min++;
    }
    if(min>60){
        hos=hos+(min/60);
        hos1=7-hos;
            if(hos1<0){
            hos1=24+hos1;
        }
        min=min%60;
        min1=60-(min+10);

    }
    else{
        hos1=7-hos;
        min1=60-(min+10);
    }
    printf("%02d:%02d",hos1,min1);
    return 0;
}

by haimingbei @ 2024-07-27 23:26:12

@MZH666 只有c++的,自己稍加改一下头文件和输入和输出吧,c不太了解(AC,求关)

#include<bits/stdc++.h>
using namespace std;
int main(){
    int s,v;
    cin>>s>>v;
    int t=s/v;
    if(s/v>3590)return 0;
    else if(s%v!=0)t++;
    int m=470-t;
    if(m<0){
        m=1440+m;
        int h=m/60,minn=m%60;
        if(h<10){
            if(minn<10)cout<<0<<h<<":"<<0<<minn;
            else cout<<0<<h<<":"<<minn;
        }
        else{
            if(minn<10)cout<<h<<":"<<0<<minn;
            else cout<<h<<":"<<minn;
        }
    }
    else{
        int h=m/60,minn=m%60;
        if(h<10){
            if(minn<10)cout<<0<<h<<":"<<0<<minn;
            else cout<<0<<h<<":"<<minn;
        }
        else{
            if(minn<10)cout<<h<<":"<<0<<minn;
            else cout<<h<<":"<<minn;
        }
    }
    return 0;
}

|