hdu 2005 第几天?(c语言)
生活随笔
收集整理的這篇文章主要介紹了
hdu 2005 第几天?(c语言)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
hdu 2005 第幾天?
link
題目描述
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 193611 Accepted Submission(s): 68291
Problem Description
給定一個日期,輸出這個日期是該年的第幾天。
Input
輸入數(shù)據(jù)有多組,每組占一行,數(shù)據(jù)格式為YYYY/MM/DD組成,具體參見sample input ,另外,可以向你確保所有的輸入數(shù)據(jù)是合法的。
Output
對于每組輸入數(shù)據(jù),輸出一行,表示該日期是該年的第幾天。
Sample Input
1985/1/20
2006/3/12
Sample Output
20
71
Author
lcy
問題解答
#include <stdio.h>int main() {int year,month,day;while(scanf("%d/%d/%d",&year,&month,&day)!=EOF){if(((year%4==0)&&(year%100!=0))||(year%400==0)){int amount=0;for(int i=1;i<month;i++){if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)amount+=31;if(i==4||i==6||i==9||i==11)amount+=30;if(i==2)amount+=29;}printf("%d\n",amount+day);}else{int amount=0;for(int i=1;i<month;i++){if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)amount+=31;if(i==4||i==6||i==9||i==11)amount+=30;if(i==2)amount+=28;}printf("%d\n",amount+day);}} }筆記
轉(zhuǎn)載于:https://www.cnblogs.com/yuzilan/p/10626220.html
總結(jié)
以上是生活随笔為你收集整理的hdu 2005 第几天?(c语言)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阿里云服务器CentOS6.9 nexu
- 下一篇: 六、配置Oracle数据库的网络环境