L1-018 Big Ben
Questions asked
There are micro-blog a self-proclaimed "Big Ben V" guy, ring the bell every day urging code farmers who care of the body to bed early. However, because Ben himself is not very regular schedule, so the bell is not timed. General bell bell points is based on time-dependent, if just knock at some point the whole, the "when" the whole is equal to the number of points; if after the whole point, you Qiaoxia a whole number of points. In addition, although 24 hours a day, but it is only the bell knock 1 to 12 under after half a day. Ring the bell at 23:00 for example, is "Dangdang Dangdang Dangdang Dangdang when", and to the 23:01 would be "Dangdang Dangdang Dangdang Dangdang Dangdang." Between midnight and 00:00 to 12:00 (end time included), Ben is not a knock.
Here you write a program, Big Ben bell for the current time.
Input format:
input of the first line in accordance with the hh:mm
format given by the current time. Wherein hh
it is the hour, between 00 to 23; mm
in minutes, between 00 and 59.
Output format:
for Big Ben bell according to the current time, i.e., a corresponding number of outputs in one line Dang
. If not ring the bell of the output:
Only hh:mm. Too early to Dang.
Which hh:mm
is the time of entry.
Sample Input 1:
19:05
Output Sample 1:
DangDangDangDangDangDangDangDang
Sample Input 2:
07:05
Output Sample 2:
Only 07:05. Too early to Dang.
code show as below:
#include<iostream>
#include<string>
using namespace std;
int main()
{
int num=0;
string str;
cin>>str;
if(str[0]=='0') //时间为00:00~09:59时
cout<<"Only "<<str<<". Too early to Dang."<<endl;
else if(str[0]=='1') //时间为10:00~19:59时
{
if(str[1]=='0' || str[1]=='1')
cout<<"Only "<<str<<". Too early to Dang."<<endl;
else if(str[1]=='2' && str[3]=='0' && str[4]=='0')
cout<<"Only "<<str<<". Too early to Dang."<<endl;
else
{
num=str[1]-'2';
if(str[3]!='0' || str[4]!='0')
num+=1;
for(int i=0;i<num;++i)
cout<<"Dang";
cout<<endl;
}
} //时间为20:00~23:59时
else
{
num=8+str[1]-'0';
if(str[3]!='0' || str[4]!='0')
num+=1;
for(int i=0;i<num;++i)
cout<<"Dang";
cout<<endl;
}
return 0;
}