buzhidao985 @ 2024-11-06 11:16:16
#include <iostream>
using namespace std;
int main()
{
double s, v;
cin >> s >> v;
if (s >= 1 && v <= 1e4)
{
double time;
int time2;
time = s / v + 10;
time2 = 8 * 60 - time;
int HH, MM;
HH = time2 / 60;
MM = time2 % 60;
printf("%02d:%02d", HH, MM);
}
system("pause");
return 0;
}
by c22j33c43 @ 2024-11-06 11:31:52
@buzhidao985 提前一天呢?
by c22j33c43 @ 2024-11-06 11:32:49
读题,不超过一天
by c22j33c43 @ 2024-11-06 11:33:46
前一天8:00之后出发也在范围里
by buzhidao985 @ 2024-11-09 16:12:19
@c22j33c43
using namespace std; int main() { double s, v; cin >> s >> v; if (s >= 1 && v <= 1e4) { double time; int time2; time = s / v + 10; time2 = 8 * 60 - time; int HH, MM; if (time < 480) { HH = time2 / 60; MM = time2 % 60; } else { if (time >= 480 && time < 1440) { HH = 24 - (time2 / 60 - 8); MM = time2 % 60; } else cout << "输入错误" << endl; } printf("%02d:%02d", HH, MM); } system("pause"); return 0; }
by buzhidao985 @ 2024-11-09 16:13:04
#include <iostream>
using namespace std;
int main()
{
double s, v;
cin >> s >> v;
if (s >= 1 && v <= 1e4)
{
double time;
int time2;
time = s / v + 10;
time2 = 8 * 60 - time;
int HH, MM;
if (time < 480)
{
HH = time2 / 60;
MM = time2 % 60;
}
else
{
if (time >= 480 && time < 1440)
{
HH = 24 - (time2 / 60 - 8);
MM = time2 % 60;
}
else
cout << "输入错误" << endl;
}
printf("%02d:%02d", HH, MM);
}
system("pause");
return 0;
}
by buzhidao985 @ 2024-11-09 16:14:56
@c22j33c43 为啥还是70分?真的跪谢
by c22j33c43 @ 2024-11-09 16:17:54
?????
by c22j33c43 @ 2024-11-09 16:18:43
@buzhidao985 输入错误哪里来的?
by c22j33c43 @ 2024-11-09 16:53:53
@buzhidao985
........
算了,直接帮你改了,AC代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
double s, v;
cin >> s >> v;
if (s >= 1 && v <= 1e4)
{
double time;
int time2;
time = s / v + 10;
time2= 8 * 60 - ceil ( time );
int HH, MM;
if (time <= 480)
{
HH = time2 / 60;
MM = time2 % 60;
}
else
{
time2+=1440;
HH = time2 / 60;
MM = time2 % 60;
}
printf("%02d:%02d", HH, MM);
}
system("pause");
return 0;
}