Inbot @ 2024-03-01 20:51:43
#include<stdio.h>
int main()
{
int HH=7, MM=50;
float s, v, t;
scanf("%f %f", &s, &v);
t = s / v;
if (t != 0)/*用时不为0时*/
MM = MM - (int)t - 1;
/*时间转换*/
while (MM >= 60)
{
HH++;
MM -= 60;
}
while (MM < 0)
{
HH--;
MM += 60;
}
/*跨天转换*/
if (HH < 0)
{
HH = 24 + HH;
}
if (HH >= 24)
{
HH = 24 - HH;
}
/*输出*/
if (HH < 10)
printf("0");
printf("%d:", HH);
if (MM < 10)
printf("0");
printf("%d", MM);
return 0;
}
by Dawn_chen @ 2024-03-01 21:23:01
@Inbot 判断时间不为零的那一段出锅了
by Dawn_chen @ 2024-03-01 21:24:51
可以将 float s, v, t
改成 int s, v, t
,后面改为
if (s % v)/*用时不为0时*/
MM = MM - t - 1;
else MM = MM - t;
by Inbot @ 2024-03-01 21:31:03
@Dawn_chen 谢谢
by Dawn_chen @ 2024-03-01 21:44:16
@Inbot 无耻地求一个关注(