Test instructions
Existing Park Boat Rental office please write a chartering management system.
When the visitor chartering, the administrator enters the ship number and presses the S key, the system starts the time, when the visitor also ships, the administrator enters the ship number and presses the E key, the system ends the timing.
The ship number is a positive integer not exceeding 100. When the administrator enters 0 as the ship number, it means that one day the chartering work is finished, the system should output the number of visitors and the average chartering time of the day.
Note: The system should be able to automatically ignore such an invalid record because the line occasionally fails and may have incomplete records, that is, only if the ship is not in the boat, or if the ship does not have a chartering record.
Input:
The test input contains several test cases, each of which is a full-day charter record in the form
Ship number (1~100) key value (s or e) occurrence time (hours: minutes)
Each day's records are guaranteed to be given in the order of time increments. When the ship number 1 is read, all inputs are completed and the corresponding results are not output.
Output:
Output 1 rows For each test case, that is, the number of visitors to the day and the average chartering time (in minutes, an integer time in units of digits).
Code:
intmp[ the];intboat[ the];intMain () {intCountt =0; intTimetot =0; intS,hour,minute; Charkind; MEM (MP,0); while(SCANF ("%d", &s), s!=-1) {GetChar (); scanf ("%c",&kind); scanf ("%d:%d",&hour,&minute); intTiming = hour* -+minute; if(s==0){ if(countt!=0) printf ("%d%d\n", Countt, (int)((Double) timetot/countt+0.5)); Elseprintf ("0 0\n"); Countt=0; Timetot=0; MEM (MP,0); }Else{ if(mp[s]==0){ if(kind=='S') {Mp[s]=7; Boat[s]=timing; } }Else{ if(kind=='E') {Mp[s]=0; ++Countt; Timetot+ = (Timing-Boat[s]); } } } } return 0;}
HDU 1861 Boat Rental (simulated problem, water)