Springmvc Learning @modelattribute uses a detailed explanation

2023-01-23   ES  

Question description:

The existing park cruise rental office, please write a charter management system. When the tourists rent a boat, the administrator enters the boat number and press the S key to start timing. When the tourist returns the ship, the administrator enters the boat number and press the E key to end the timing. The ship number is a positive integer with no more than 100. When the administrator enters 0 as a boat number, it means that the one -day rental work is over, and the system should output the number of tourists on the day of the day.
Note: Because the line occasionally has a failure, there may be incomplete records, that is, only the rental ship does not return the ship, or the record of returning a ship or renting a ship should automatically ignore this invalid record.
Input:

Test input contains several test cases. Each test case is a full day of rental record. The format is:
boat number (1 ~ 100) key value (s or e) occurring time (hour: minute)
The record of each day guarantees the order of time. When you read the ship number -1, the input is over, and the corresponding results should not be output.

output:

Output 1 row for each test case, that is, the number of tourists on the day and the average rental time of the rent (the accurate to the integer time of the unit in minutes).
sample input:

1 S 08:10
2 S 08:35
1 E 10:00
2 E 13:16
0 S 17:00
0 S 17:00
3 E 08:10
1 S 08:20
2 S 09:00
1 E 09:20
0 E 17:00
-1
Sample output:

2 196
0 0
1 60
AC code:
#include <stdio.h> 
 #include <math.h> 

 struct record { 
 int ID; 
 char ch; 
 int T; 
 int Flag; 
 }; 

 int main () {) 
 //freopen 18"in.txt",s",stdin); 
 
 Record Records [200]; 
 Record R; 
 int n, hh, mm, num; 
 double sum, average; 
 While (Scanf ("%D%C%D%*C%D", & r.id, & r.ch, & hh, & mm) && r.id! =-1) { 
 if (r.id == 0) { 
 Printf ("0 0 \ n"); 
 constinue; 
 } 
 n = 0; 
 num = 0; 
 sum = 0; 
 R.T = HH*60 + mm; 
 r.flag = 0; 
 Records [n ++] = r; 
 While (Scanf ("%D%C%D%*C%D", & r.id, & r.ch, & hh, & mm) && r.id! = 0) { 
 R.T = HH*60 + mm; 
 r.flag = 0; 
 if (r.ch == 's') {{ 
 Records [n ++] = r; 
 } else { 
 for (int i = 0; i <n; i ++) { 
 if (r.id == records [i] .id && records [i] .flag == 0) { 
 SUM += R.T-RECORDS [i] .t; 
 num ++; 
 Records [i] .flag = 1; 
 Break; 
 } 
 } 
 } 
 } 
 if (num == 0) // The number of ship rental is 0 
 Printf ("0 0 \ n"); 
 else { 
 average = sum / num; 
 Printf (" %d %.0lf \ n", num, CEIL (Average); // Applicable on the ACMCLUB with a decimal number 
 // Printf (" %d %.0lf \ n", num, average); // Four House and Five Entry Nine Degree and HDOJ applicable 
 } 
 } 
 
 Return 0; 
 }

source

Related Posts

pHP TP5 framework send text message verification code AAA1

Image and picture shadow mobile Avecle

[Large screen project] SpringBoot + Vue implemented visualized drag editor

Spring Boot timing task

Springmvc Learning @modelattribute uses a detailed explanation

Random Posts

serialization tool — Introduction to Object Serialization Library MSGPACK Introduction

Robot controller programming teaching progress table

ISO BLE connection parameter limit LIFE

RS232 serial port line connection method and line core drawing definition

Lead-Leading Website-Solid Network based on the technical inside of J2EE Resin