不会……

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

great_mad @ 2023-10-31 13:17:58

#include <stdio.h>
int main()
{
    int s,v;
    scanf("%d %d",&s,&v);
    int min = (double)s/v+10;
    int a = 8 * 60 - min;
    printf("%2d:%2d",a/60,a%60);
    return 0;
}

by Steve_xh @ 2023-10-31 13:26:22

printf占位符是%02d吧


by Steve_xh @ 2023-10-31 13:30:20

@great_mad


by great_mad @ 2023-10-31 13:34:14

#include <stdio.h>
int main()
{
    int s,v;
    scanf("%d %d",&s,&v);
    int min = (double)s/v+10;
    int a = 8 * 60 - min;
    printf("%02d:%02d",a/60,a%60);
    return 0;
}

by great_mad @ 2023-10-31 13:34:55

@Steve_xh 还有其他错的地方


by zheng_zx @ 2023-10-31 13:38:01

前面没补 0 而且算错了


by _Spectator_ @ 2023-10-31 13:43:07

@great_mad

  1. 时间向上取整 min = ceil(s*1.0/v)+10
  2. 有可能要在前一天就出发 if(a<0) a+=1440;

|