Big Ben (10 points) C language

 

 

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 a day for 24 hours, 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 formats:

Input of the first line in accordance with hh:mmthe format given by the current time. Wherein hhit is the hour, between 00 to 23; mmin minutes, between 00 and 59.

Output formats:

Big Ben bell for 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:mmis 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.
 #include <stdio.h>

int main()

{

    int h,m,i,sum;

char *s="Dang";

    scanf("%d:%d",&h,&m);

    sum=(h-12)+(m==0?0:1);

    if(sum>0)

    {

        for(i=0;i<sum;i++)//区间端点不dang

        printf("%s",s);

    } else{

        printf("Only %d",h/10);

        printf("%d",h%10);

        printf(":%d",m/10);

        printf("%d",m%10);

        printf(". Too early to Dang.");

    }

    return 0;

}

 

Released nine original articles · won praise 4 · Views 1505

Guess you like

Origin blog.csdn.net/qq_36667885/article/details/104071918
Recommended