1105: 零起點學算法12——求2個日期之間的天數
Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 4404 Accepted: 1985
[Submit][Status][Web Board]
Description
水題
Input
輸入2個日期,日期按照年月日,年月日之間用符號-隔開(題目包含多組數據)
Output
求出這2個日期之間的天數(不包括自身),每組測試數據一行
Sample Input 
2011-1-1
2011-1-5
Sample Output
3
HINT
為了簡單之見,本題假設輸入的是同年同月的2個日期,且第一個日期小於第2個日期
Source
1 #include<stdio.h> 2 int main(){ 3 int y1,y2,m1,m2,d1,d2; 4 while(scanf("%d-%d-%d%d-%d-%d",&y1,&m1,&d1,&y2,&m2,&d2)!=EOF){ 5 printf("%d\n",d2-d1-1); 6 } 7 return 0; 8 }