The time interval for the brain
来源:互联网 发布:网络电影痞子兵王 编辑:程序博客网 时间:2024/06/03 15:59
Problem Description
从键盘输入两个时间点(24小时制),输出两个时间点之间的时间间隔,时间间隔用“小时:分钟:秒”表示。
如:3点5分25秒应表示为--03:05:25.假设两个时间在同一天内,时间先后顺序与输入无关。
如:3点5分25秒应表示为--03:05:25.假设两个时间在同一天内,时间先后顺序与输入无关。
Input
输入包括两行。
第一行为时间点1。
第二行为时间点2。
第一行为时间点1。
第二行为时间点2。
Output
以“小时:分钟:秒”的格式输出时间间隔。
格式参看输入输出(There is no blank line between the two lines of data)。
格式参看输入输出(There is no blank line between the two lines of data)。
Example Input
12:01:12
13:09:43
Example Output
01:08:31
Although this problem is simple, but still stumped a lot of small partners, the key is to successfully convert the unit and then converted back.Many of the problems can use the idea of transformation to complete, or even a little conversion, you become the most familiar template.
//AC Code presented#include <stdio.h>#include <stdlib.h>int main(){ int h1,m1,s1,h2,m2,s2; int t1,t2,t; int ans1,ans2,ans3; char ch; scanf("%d%c%d%c%d\n",&h1,&ch,&m1,&ch,&s1);//Read scanf("%d%c%d%c%d",&h2,&ch,&m2,&ch,&s2); t1=3600*h1+60*m1+s1;//Calculate time 1 t2=3600*h2+60*m2+s2;//Calculate time 2 t=abs(t1-t2);//Does not rule out the time 2 than the time 1 early, so to calculate ABS ans3=t%60;//Convert the time difference into the form of the subject requirement ans2=((t-ans3)%3600)/60; ans1=(t-ans3-ans2*60)/3600; if (ans1<10) printf("0%d:",ans1); else printf("%d:",ans1);//The output format should be correct if (ans2<10) printf("0%d:",ans2); else printf("%d:",ans2); if (ans3<10) printf("0%d:",ans3); else printf("%d",ans3); return 0;}
//Look at the code of the little partners, please do not copy and paste directly, even if the copy is responsible for their own.
阅读全文
0 0
- The time interval for the brain
- For the first time!
- The Time for sprint
- just for the first time
- POJ1007 for the first time
- The Last Time For Yourself!
- 1 the brain and behavior
- <Brain> The Anatomy of Movement
- 读论文《The perceptron: A probabilistic model for information storage and organization in the brain》
- The Brain is wider than the Sky !
- ubuntu taste for the first time
- learning jsp for the 2nd time
- The Case For Automating Manual Time Tracking
- The importance of Scheudling for Time Management
- OATH FOR MYSELF(Updata all the time)
- prepare for the provincial time --10.5--Friends
- It's time for the first article
- The time
- 1000. 链式队列
- Java语言基础小结8
- localhost与127.0.0.1的区别
- Http get与pos
- 五分钟理解一致性哈希算法(consistent hashing)
- The time interval for the brain
- Java -- Thread习题(1)
- centos7 如何卸载yum 安装的php
- iOS OC和swift更改状态栏的颜色
- 使用CSS完成元素居中的七种方法
- new ActiveXObject("Scripting.FileSystemObject") 未能创建对象的解决方法
- Oracle归档模式下恢复-recover期间归档日志文件使用
- HDOJ2018
- Monte Carlo , 蒙特卡洛算法