Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <cstring>
- using namespace std;
- char s[10];
- int len[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, j;
- string res[10];
- int main() {
- freopen("chronicle.in", "r", stdin);
- freopen("chronicle.out", "w", stdout);
- int a[3];
- scanf("%d/%d/%d", &a[0], &a[1], &a[2]);
- int p[] = {0, 1, 2};
- bool ok = false;
- do {
- int d = a[ p[0] ];
- int m = a[ p[1] ];
- int y = a[ p[2] ];
- if (m > 12 || m == 0 || d == 0)
- continue;
- m--;
- if (y % 4 == 0 && y != 0)
- len[1]++;
- if (d <= len[m]) {
- sprintf(s, "%02d/%02d/%02d\n", d, m + 1, y);
- for (int i = 0; i < 8; i++)
- res[j] += s[i];
- j++;
- ok = true;
- }
- if (y % 4 == 0 && y != 0)
- len[1]--;
- }
- while (next_permutation(p, p + 3));
- if (!ok)
- puts("No such date\n");
- else {
- sort(res, res + j);
- cout << res[0] << endl;
- for (int i = 1; i < j; i++)
- if (res[i] != res[i - 1])
- cout << res[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement