makingtimefor @ 2024-08-11 22:49:04
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int s,v,t;
cin>>s>>v;
t=s/v;
if(s%v!=0){
//TODO
t++;
}
int hour=7,min=50;
int t_h=t/60;
int t_m=t%60;
hour-=t_h;
min-=t_m;
if(min<0){
min+=60;
hour-=1;
}
if(hour<=0){
//TODO
hour+=24;
}
if(hour>10&&min>10){
//TODO
cout<<hour<<":"<<min<<endl;
}
else if(hour<10&&min>10){
cout<<"0"<<hour<<":"<<min<<endl;
}
else if(hour>10&&min<10){
cout<<hour<<":"<<"0"<<min<<endl;
}
else{
cout<<"0"<<hour<<":"<<"0"<<min<<endl;
}
return 0;
}
by dc_ansan_tangmingyi @ 2024-08-12 13:18:00
@makingtimefor
1.建议用printf("%02d:%02d",hour,min)
格式化输出。
2.把if(hour<=0)
改成if(hour<0)
。
by dc_ansan_tangmingyi @ 2024-08-12 13:18:29
AC CODE:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int s,v,t;
cin>>s>>v;
t=s/v;
if(s%v!=0){
t++;
}
int hour=7,min=50;
int t_h=t/60;
int t_m=t%60;
hour-=t_h;
min-=t_m;
if(min<0){
min+=60;
hour--;
}
if(hour<0){
hour+=24;
}
printf("%02d:%02d",hour,min);
return 0;
}