Problem E: 校庆
生活随笔
收集整理的這篇文章主要介紹了
Problem E: 校庆
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Problem E: 校慶
Time Limit:?1 Sec??Memory Limit:?128 MBSubmit:?1520??Solved:?574
Description
2017年10月28日是zstu的120周年校慶,撒花,撒花。為此KI決定設(shè)計(jì)一個程序,來慶祝我們的校慶:
?? 給出某一天的日期year-month-date, 求這一天到2017-10-28還差幾天。
Input
第一行有個整數(shù)T, 表示測試組數(shù)。T≦100。
接下來每個測試組,給出三個數(shù)year month date。(1900 <=year <=2017?), 保證每個日期均合法,并且小于2017-10-28。
Output
對于每個測試組,請輸出對應(yīng)的答案。
Sample Input
1 2017 10 1Sample Output
27 #include<string> #include<iostream> #include<cstdio> using namespace std; int main(){ int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; for(int i=1;i<13;i++)a[i]=a[i]+a[i-1];int sum=2016*365+2016/4-2016/100+2016/400+a[9]+28;int t;cin>>t;while(t--){int y,m,d;cin>>y>>m>>d;int sum1=(y-1)*365+(y-1)/4-(y-1)/100+(y-1)/400+a[m-1]+d;if((y%4==0&&y%100)||y%400==0)if(m>=3)sum1++;printf("%d\n",sum-sum1);} }總結(jié)
以上是生活随笔為你收集整理的Problem E: 校庆的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言fscanf函数了解
- 下一篇: 算术表达式的前缀式、中缀式、后缀式相互转