不需要判断两个时间的大小,直接(b-a+24)%24
C++ 代码
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
if(a == b) printf("O JOGO DUROU 24 HORA(S)");
else printf("O JOGO DUROU %d HORA(S)",(b-a+24)%24);
return 0;
}