C++30分求助,希望大佬能帮忙看看

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

@[666tina](/user/841554) 你好像没写前一天晚上出发的情况
by guozhe6241 @ 2023-01-16 23:33:43


```cpp #include<iostream> using namespace std; int main() { int s, v,t,n; int HH, MM; cin >>s >> v; t = s / v+10;//时间 if (s % v != 0) t = t + 1;//判断t是否为整数 n = t / 60; if (t <480) { HH = 7 - n; MM = 60 - (t - 60 * n); } else if (t > 480 && t < 1440) { HH = 24 - (n - 8); MM = 60 - (t - 60 * n); if (HH == 24) { HH = 0; } } if (HH < 9) { if (MM < 9) { cout << 0 << HH << ':' << 0 << MM; } else cout << 0 << HH << ':' << MM; } else { if (MM < 9) { cout << HH << ':' << 0 << MM; } else { cout << HH << ':' << MM; } } return 0; }
by 666tina @ 2023-01-17 15:16:07


@[guozhe6241](/user/823122) 这样可以吗,现在写进去,为什么还是没办法AC,麻烦大佬了,十分感谢
by 666tina @ 2023-01-17 15:17:17


```cpp //帮忙测试的,希望不要被认为抄别人代码 #include<iostream> using namespace std; int main() { int s, v,t,n; int HH, MM; cin >>s >> v; t = s / v+10; if (s % v != 0) t = t + 1; n = t / 60; if (t <=480) { HH = 7 - n; MM = 60 - (t - 60 * n); } else if (t > 480 && t < 1440) { HH = 7+24 - n ; MM = 60 - (t - 60 * n); if (HH == 24) { HH = 0; } } if (HH <= 9) { if (MM <= 9) { cout << 0 << HH << ':' << 0 << MM; } else cout << 0 << HH << ':' << MM; } else { if (MM <= 9) { cout << HH << ':' << 0 << MM; } else { cout << HH << ':' << MM; } } return 0; } ``` @[666tina](/user/841554) 这样子就AC了
by guozhe6241 @ 2023-01-17 23:14:31


@[guozhe6241](/user/823122) 谢谢大佬
by 666tina @ 2023-01-22 17:42:49


|