Whether you have a bad mood in a day?

From CS100 Homework 1-3

题目描述

As you have all experienced, before your first semester starts, there are many lectures (like school introduction, fire safety and such) for new students, and they are MANDATORY.

Of course, the contents of those lectures are very beneficial to new students, but there are always some who don’t like the lectures, and here begins our story of Gezi Wang, a lazy freshman.

Gezi Wang’s day begins when he wakes up at8:00with mood level100. 100 is also the maximum limit of his mood level.

During his day, several lectures will take place. Gezi Wang has to attend these lectures, but his mood level will drop.

For the first 60 minutes of a lecture, his mood level drops by0.4/minute.

After 60 minutes, his mood level drops by0.8/minute.

If his mood drops to or below 0, we will assume he has to be sent to the hospital.

When Gezi Wang does not have a lecture, he immediately returns to his dorm and sleeps.

His mood recovers by0.5/minutein this situation.

His mood level will not exceed the maximum limit 100.

His day ends at22:00. Your goal is to find out his mood level at the end of the day.

The following is a demo process of the program: (red indicates input)

image
问题输入

You will receivean integerin the first line, indicating the number of lectures today.

In each of the following line, you will receivetwo 24-hour times, separated by a hyphen (-). (Sample: 11:00-13:00) This indicates when a lecture starts and ends.

It’s guaranteed that the inputs are as valid as you can imagine, specifically that:

1.There is no lecture before 8:00 and after 22:00.
2.The lectures will be given in time order. In other words, after a line of “14:00-14:30”, you won’t receive a time period such as “9:00-10:00”.
3.The end time of a lecture is always later than the beginning time.
4.No lectures overlap, and there are always breaks between lectures. (And no matter how short a break is, he sleeps!)

Note that it is not certain how many lectures there are, so we recommend not using an array.

问题输出

Your output will be one line at the beginning and one line in the end.

At the beginning, you should write:

How many lectures today?, followed by a new line(\n).

After all inputs, you must give your output in the following format:

If Gezi Wang is not sent to hospital during his day, you should write:

His mood level is *** at the end of the day.

* The mood level should be printed with “printf” to display only 1 decimal point digit, even if it is an integer.

Otherwise, you should write:

Gezi Wang has been sent to hospital.

样例输入1
3
9:00-11:00
15:00-17:00
17:30-18:50
样例输出1
How many lectures today?
His mood level is 98.0 at the end of the day.


样例输入2
1
8:01-21:59
样例输出2
How many lectures today?
Gezi Wang has been sent to hospital.
在线测试 (语言:C;时间限制:1s)
当前状态

无提交记录

有话想说?