时间差
10點半到11點45之間,有幾小時幾分鐘呢?
你要寫一個程序,讀入兩個時間,計算它們之間的時間差,輸出相差幾小時幾分鐘。
輸入
輸入兩個時間,均以24小時制表達,每個時間以“小時:分鐘”的形式表達,第二個時間一定比第一個時間晚或相同,而且一定在同一天內。
輸出
輸出表示兩個時間之間的時間差的兩個數字,第一個數字是時間差中的小時數,第二個數字是時間差中的分鐘數。
輸入例子
10:30 11:45
輸出例子
1 15
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) {int a=0,b=0,c=0,d=0,time=0;scanf("%d:%d %d:%d",&a,&b,&c,&d);time=c*60+d-a*60-b;printf("%d %d",time/60,time%60);return 0; }總結
- 上一篇: 【安全牛学习笔记】COWPATTY 破解
- 下一篇: 【原创】【学习笔记5】关于console