运用map映射 简化问题 但要注意一些小细节 当一个人都没有借的时候
#include<bits/stdc++.h>
using namespace std;
int main()
{
map<int,char> map1;
map<int,int> map2;
int n,hour,minnue,number,t=0,num=0;
char s[5];
cin>>n;
while(n--)
{
while(scanf("%d%s%d:%d",&number,s,&hour,&minnue)!=EOF)
{
if(number==0) break;
if(s[0]=='S')
map1[number]='S',map2[number]=hour*60+minnue;
else if(s[0]=='E')
if(map1[number]=='S')
t+=(hour*60+minnue-map2[number]),map1[number]='0',map2[number]=0,num++;
}
printf("%d %.0f
",num,num==0?num:t*1.0/num); //特判一个人都没有借的情况
t=0;num=0;map1.clear(),map2.clear(); //多个输入情况最后千万不能忘记清空
}
return 0;
}