90分求助,#9WA

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

yu1128 @ 2023-12-28 18:09:31

#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a,b;
    int c;
    double d,e;
    cin>>a>>b;
    c=int(a/b+0.999999999)+10;
    d=int((8-ceil(c/60.0)));
    if(d<0) d+=24;
    e=60-(c+1)%60;
    if(d<10){
        if(e<10) cout<<"0"<<d<<":"<<"0"<<e;
        else cout<<"0"<<d<<":"<<e;
    }
    else{
        if(e<10) cout<<d<<":"<<"0"<<e;
        else cout<<d<<":"<<e;
    }
}

by a1111a @ 2023-12-30 10:29:26

a/b没强制转换成double


by a1111a @ 2023-12-30 10:53:29

#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a,b;
    int c;
    double d,e;
    cin>>a>>b;
    c=int((double)a/b+0.999999999)+10;
    d=int((8-ceil(c/60.0)));
    if(d<0) d+=24;
    e=60-(c+1)%60;
    if(d<10){
        if(e<10) cout<<"0"<<d<<":"<<"0"<<e;
        else cout<<"0"<<d<<":"<<e;
    }
    else{
        if(e<10) cout<<d<<":"<<"0"<<e;
        else cout<<d<<":"<<e;
    }
}

by yu1128 @ 2024-02-14 19:59:38

@a1111a ,0分


by a1111a @ 2024-02-15 10:42:14

@yu1128

#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a,b;
    int c;
    double d,e;
    cin>>a>>b;
    c=int((double)a/b+0.999999999)+10;
    d=int((8-ceil(c/60.0)));
    if(d<0) d+=24;
    e=60-c%60;
    if(d<10){
        if(e<10) cout<<"0"<<d<<":"<<"0"<<e;
        else cout<<"0"<<d<<":"<<e;
    }
    else{
        if(e<10) cout<<d<<":"<<"0"<<e;
        else cout<<d<<":"<<e;
    }
}

还有这个,e=60-c%60;不是e=60-(c+1)%60


by yu1128 @ 2024-02-15 13:04:48

A了,谢谢


|