本来觉着时间好复杂,不知道怎么计算和存储,看了别人的才懂。以后还是要多加练习。
#include <stdio.h>
#include <string.h>
struct boat{
int flag;//´¬ÊÇ·ñ±»½è³ö
int num;
int start;
int time;
}Boat[105];
int main()
{
int i,num,hour,minute,count;
char key;
double t;
while(scanf("%d",&num)!=EOF&&num!=-1){
count=0;
t=0;
while(num!=0){
scanf(" %c %d:%d",&key,&hour,&minute);
if(key=='S'){
Boat[num].num=num;
Boat[num].flag=1;
Boat[num].start=hour*60+minute;
}
else if(key=='E'){
if(Boat[num].flag==1){
Boat[num].time=hour*60+minute-Boat[num].start;
count++;
t+=Boat[num].time;
}
}
scanf("%d",&num);
}
scanf(" %c %d:%d",&key,&hour,&minute);
if(count!=0)
printf("%d %.0f\n",count,t/count);
else
printf("0 0\n");
}
return 0;
}