当前位置:网站首页>C language daily question - xiaolele alarm clock (niuke.com)
C language daily question - xiaolele alarm clock (niuke.com)
2022-04-22 03:13:00 【Hair is not as much as code】
describe
Xiaolele is lazy , He wants to sleep now , Then go to study . He knows the moment , And how long you want to sleep , I want to set an alarm clock to wake him up and study , But he's so stupid , I don't know when to set the alarm clock , Please help him .( Only time and minutes are considered , Regardless of the date )
Input description :
Enter the current time and the length of sleep k( Company :minute), Separate... With spaces in the middle .
Input format :hour:minute k( Such as hour or minute The value of is 1, Input is 1, instead of 01)
(0 ≤ hour ≤ 23,0 ≤ minute ≤ 59,1 ≤ k ≤ 109)
Output description :
For each group of input , Output the time that the alarm clock should set , The output format is standard time representation ( Both instant and minute are composed of two Who said , The number of digits is not enough. Use the leading 0 A filling ).
Example 1
Input :
0:0 100Output :
01:40
Example 2
Input :
1:0 200 Output :04:20
#include<stdio.h>
int main()
{
int a, b, c, d;
scanf("%d:%d %d", &a, &b, &c); // When you enter three numbers that are starting Minutes and set length of time , In minutes
d = a + (b + c) / 60; //(b+c)/60 Add up the values in minutes, convert them to hours, and then +a Add the original tense ,d= Final time position
printf("%02d:%02d", d % 24,(60 * a + b + c - 60 * d)%60);//d%24 Yes 24 Take the surplus to prevent exceeding 24 Hours ,60*a+b+c-60*d // 60*a Convert the number on the time bit into bit division , Again +b+c Divide all digitization into ,-60*d Total minutes minus Length of time in time position , The rest is naturally the duration of quantile , Yes 60 Remainder , To prevent exceeding 60
return 0;
}
Be careful : Take the remainder of the time position , Take the remainder of the quantile , To prevent exceeding 24 and 60
版权声明
本文为[Hair is not as much as code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211352336142.html
边栏推荐
- OneFlow 的 Global Tensor 学习笔记和实习总结
- Workplace etiquette How to use foreign enterprise email
- 剑指offer 专项突破版 91、粉刷房子
- twenty-eight. Built in module
- twenty-seven. Package (import)
- 微信JSAPI支付方式与错误(当前页面的URL未注册,支付验证签名失败)
- Driverless virtual simulation (14) -- traffic sign recognition in image processing 2
- How to run collabora office in openshift
- Ros2 learning notes (V) -- Summary of common instructions for ros2 command line operation (I)
- [WUSTCTF2020]朴实无华
猜你喜欢

Serviceworker cache and HTTP cache

Driverless virtual simulation (13) -- traffic sign recognition in image processing 1

Kerberos authentication protocol

Niu Ke's entry record of C language

Rest assured obtains logs to files and displays them in combination with the allure report

Technology sharing | selenium ide use case recording

Saas.扩展字段 自定义字段

500错误,提交响应后无法转发

Interpretation of Flink's new features of fine-grained resource management

Pytest automated testing framework (2)
随机推荐
Jiarong Technology Shenzhen Stock Exchange listed and discovered: The Value of Market of the company is 4.1 billion, and the Accounts receivables are 280 million.
如何通过沟通激发开放性思维
JS表格排序
Introduction of explanatory variables in code refactoring
二十七.包(import)
leetcode:297. Serialization and deserialization of binary tree
tetracosa-. Deep and shallow copies of classes
二十五.模块/内置模块/模块的安装
Troubleshooting kubernetes - 10s delay
Favorite tips link
Sword finger offer special breakthrough version 91. Painting the house
Openshift enterprise test environment application deployment practice
Serviceworker cache and HTTP cache
Application packaging or test team?
Using pytest to play with data-driven testing framework
微信H5支付(报跨域问题)
第9章 内核同步介绍
Inline function of code refactoring
kerberos認證協議
go语言实战-----30-----token机制微信公众号签名验证的方法、XML解析,CDATA解析、交换协议、接收消息协议、被动回复消息协议、正则表达式