#include <bits/stdc++.h>
using namespace std;
int N;
int h1, m1, h2, m2;
int sum(int h1, int m1, int h2, int m2)
{
int total = 0;
int sleep = (h2 * 60 + m2) - (h1 * 60 + m1);
if (sleep < 0)
{
sleep += 24 * 60;
}
total += sleep;
return total;
}
int main()
{
freopen("r", "sleep.in", stdin);
freopen("w", "sleep.out", stdout);
cin >> N;
int total = 0;
while (N--)
{
char c;
cin >> h1 >> c >> m1 >> h2 >> c >> m2;
total += sum(h1, m1, h2, m2);
}
cout << total << endl;
fclose(stdin);
fclose(stdout);
return 0;
}
上面是代码,文件读写有,但是没有输出文件,应该是没有读到文件(我试过fin了)