star_sink @ 2024-05-16 20:11:29
#include<bits/stdc++.h>
using namespace std;
int main(){
double s,v;
int n,t,a,b;
cin>>s>>v;
n=24*60+8*60;
t=ceil(s/v)+10;
n=n-t;
if(n>=24*60){
n-=24*60;
}
a=n/60;
b=n%60;
if(a<10){
if(b<10){
cout<<"0"<<a<<":"<<"0"<<b<<endl;
}
if(b>10){
cout<<"0"<<a<<":"<<b<<endl;
}
}
if(a>10){
if(b<10){
cout<<a<<":"<<"0"<<b<<endl;
}
if(b>10){
cout<<a<<":"<<b<<endl;
}
return 0;
}
}
各位大佬,为啥#10掉了啊qwq
by luobotianle @ 2024-05-16 20:41:06
漏了对
判断部分应该打成这样:
if(a<10){
if(b<10){
cout<<"0"<<a<<":"<<"0"<<b<<endl;
}
if(b>=10){
cout<<"0"<<a<<":"<<b<<endl;
}
}
if(a>=10){
if(b<10){
cout<<a<<":"<<"0"<<b<<endl;
}
if(b>=10){
cout<<a<<":"<<b<<endl;
}
}
by luobotianle @ 2024-05-16 20:42:54
一般来说如果只有两种情况,另一种用 else
就好了,能够避免漏掉一些情况。
就像这样:
if(a<10){
if(b<10){
cout<<"0"<<a<<":"<<"0"<<b<<endl;
}
else{
cout<<"0"<<a<<":"<<b<<endl;
}
}
else{
if(b<10){
cout<<a<<":"<<"0"<<b<<endl;
}
else{
cout<<a<<":"<<b<<endl;
}
}