火车运行时间差问题 求详细代码 多谢

输入time1 = 615表示火车开始时间,输入time2 =2313表示火车到达时间,输出火车的路程时间 其中615要转化成6:15 2313转化成23:13 数字转化为时间格式 求详细代码 多谢

 我们做一个假设,如果t1>t2,那么第二天到,否则当天晚一些时候到(但是这不一定成立,上海到拉萨的火车就要开好几天)
那么可以这么算
int t1 = 615;
int t2 = 2313;
int tx1 = t1 / 100 * 60 + t1 % 100;
int tx2 = t2 / 100 * 60 + t2 % 100;
if (tx1 > tx2) tx2 = tx2 + 24 * 60;
int r = tx2 - tx1;
cout << "经过时间:" << r / 60 << ":" << r % 60;