C Language Programming _zju--3rd week 1_ Time conversion

Source: Internet
Author: User

1 time conversion (5 points)

Topic content:

When UTC is world-coordinated, the BJT is Beijing time, and UTC time equals the BJT minus 8. Now, your program reads an integer representing the time and minutes of the BJT. The number of bits and 10 digits of an integer represents the minute, and the hundred and thousands denote hours. If the hour is less than 10, there is no thousand part; If the hour is 0, there are no hundred parts, and if the hour is not 0 and the score is less than 10 points, 10 of the 0 bits are required, and 0 on 10 is not required if the hour is 10 and less than 0 points. If 1124 represents 11:24, while 905 means 9:5, 36 means 0:36, and 7 is 0:7.

The valid input range is 0 to 2359, which means that your program cannot read from the test server to input data from 0 to 2359.

Your program will output the UTC time corresponding to this time, the output format and input is the same, that is, the output of an integer, the time and minutes of UTC. The number of bits and 10 digits of an integer represents the minute, and the hundred and thousands denote hours. If the hour is less than 10, there is no thousand part; If the hour is 0, there are no hundred parts, and if the hour is not 0 and the score is less than 10 points, 10 of the 0 bits are required, and 0 on 10 is not required if the hour is 10 and less than 0 points.

Caution: Be careful with cross-day conversions.

Input format:

An integer that represents the time and minute of the BJT. The number of bits and 10 digits of an integer represents the minute, and the hundred and thousands denote hours. If the hour is less than 10, there is no thousand part; If the hour is 0, there are no hundred parts, and if the hour is not 0 and the score is less than 10 points, 10 of the 0 bits are required, and 0 on 10 is not required if the hour is 10 and less than 0 points.

Output format:

An integer that represents the time and minute of UTC. The number of bits and 10 digits of an integer represents the minute, and the hundred and thousands denote hours. If the hour is less than 10, there is no thousand part; If the hour is 0, there are no hundred parts, and if the hour is not 0 and the score is less than 10 points, 10 of the 0 bits are required, and 0 on 10 is not required if the hour is 10 and less than 0 points.

Input Sample:

803

Sample output:

3

time limit: 500ms memory limit: 32000kb
1#include <stdio.h>2 intMain () {3     intBJT,UTC;4     intBjt_h,bjt_m,utc_h;5scanf"%d",&BJT);6bjt_h=bjt/ -;7     if(bjt_h<=7){8utc_h=bjt_h+ -;9}Else{Tenutc_h=bjt_h-8;  One     } Abjt_m=bjt% -; -     if(utc_h==0){ -Utc=bjt_m; the}Else{ -utc=utc_h* -+bjt_m;  -     } -printf"%d", UTC);  +     return 0; -}

37min

My solution.

Source of the topic

Introduction to Programming--c language _ Zhejiang University-China University Mooc (MU Class) http://www.icourse163.org/course/ZJU-199001

C Language Programming _zju--3rd week 1_ Time conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.