80,倒3倒1过不去,救命

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

else第二个大括号被吞了,原来是有的
by _nonsense @ 2022-10-10 20:42:45


@[zhenshidada](/user/824349) ``` #include<bits/stdc++.h> using namespace std; signed main() { int s,u,t; scanf ("%d%d",&s,&u); if ( s%u == 0) { t=s/u; t+=9; } else { t=s/u; t+=10; } int h; int m; h = 7; m = 59; while (t != 0) { if (m != 0) { m--; } else { if (h!=0) { h--; m=59; } else { h=23; m=59; } } t--; } int a,b; int c,d; a = h/10; b = h-(10*(h/10)); c = m/10; d = m-(10*(m/10)); printf ("%d%d:%d%d",a,b,c,d); return 0; } ```
by SZH0523 @ 2022-10-10 20:49:08


@[zhenshidada](/user/824349) 精度错误,如果除出来是个小数就还多需要一分钟,也就是t-- ```cpp # include <stdio.h> #include<cmath> int main (){ int s, v, h, m, q; int t; scanf("%d %d", &s, &v); t = 470 - ceil(s*1.0/v); q = (int) t; if (q >= 0){ h = q / 60; m = q % 60; }else{ int p = 1440 + q; h = p / 60; m = p % 60; } printf("%02d:%02d", h, m); return 0; } ```
by Da_un @ 2022-10-10 21:04:08


@[Da_un](/user/311037) 嗷!懂了,谢谢你
by _nonsense @ 2022-10-10 21:12:47


@[SZH0523](/user/760455) 没学c++,但勉强看懂,谢谢你
by _nonsense @ 2022-10-10 21:13:56


|