Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- bool checkYear(int year)
- {
- return (((year % 4 == 0) && (year % 100 != 0)) ||
- (year % 400 == 0));
- }
- int main(int argc, char const *argv[])
- {
- int n, csn = 1;
- cin >> n;
- while (n--)
- {
- string ss, kk;
- int d1, y1, d2, y2;
- cin >> ss;
- scanf("%d,%d", &d1, &y1);
- cin >> kk;
- scanf("%d,%d", &d2, &y2);
- int cnt = 0;
- for (int i = y1; i <= y2; ++i)
- {
- if ( i == y1 && checkYear(y1) )
- {
- if (d1 <= 29 && (ss == "January" || ss == "February"))
- {
- cnt++;
- }
- }
- else if ( i == y2 && checkYear(y2) )
- {
- if (d2 >= 29 && (kk != "January" || kk != "February"))
- {
- cnt++;
- }
- }
- else
- {
- if (checkYear(i))
- {
- cnt++;
- }
- }
- }
- printf("Case %d: ", csn++ );
- cout << cnt << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement