Advertisement
Hippskill

Untitled

Jan 25th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include<stdio.h>
  3. #include<iostream>
  4. #include<vector>
  5. #include<cmath>
  6. #include<algorithm>
  7. #include<map>
  8. #include<set>
  9. #include<sstream>
  10. #include<cstring>
  11. #include<numeric>
  12. #include<limits.h>
  13. using namespace std;
  14.  
  15.  
  16.  
  17. int c[12]{
  18.     31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  19. };
  20. map<int, vector<int>> res;
  21.  
  22. string name[7]{
  23.     "mon", "tue", "wed", "thu", "fri", "sat", "sun"
  24. };
  25.  
  26. int main() {
  27. #ifndef ONLINE_JUDGE
  28.     freopen("input.txt", "r", stdin);
  29. #endif
  30.     int s = 5;
  31.     int d, m, y;
  32.     scanf("%d%d%d", &d, &m, &y);
  33.     int start = -1;
  34.     for (int i = 1600; i <= y; i++) {
  35.         for (int j = 1; j <= 12; j++) {
  36.             int delta = 0;
  37.             if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
  38.                 if (j == 2) {
  39.                     delta++;
  40.                 }
  41.             }
  42.             for (int z = 1; z <= c[j - 1] + delta; z++) {
  43.                 if (y == i && j == m) {
  44.                     if (start == -1)
  45.                         start = s;
  46.                     res[s].push_back(z);
  47.                 }
  48.                 s++;
  49.                 s %= 7;
  50.             }
  51.         }
  52.     }
  53.     for (auto i : res) {
  54.         printf("%s", name[i.first].c_str());
  55.         bool prev = false;
  56.  
  57.         if (i.second.size() == 5 && (*i.second.rbegin() == 30 || *i.second.rbegin() == 31)) {
  58.             if (start > i.first) {
  59.                 if (i.first == 0 || i.first == 1) {
  60.                     printf("     ");
  61.                 }
  62.             }
  63.         }
  64.         if (i.second.size() != 5) {
  65.             if(start > i.first)
  66.                 printf("     ");
  67.         }
  68.         for (auto j : i.second) {
  69.             if (j / 10 == 0 && j != i.second[0])
  70.                 printf(" ");
  71.             if (j == d) {
  72.                 if (j / 10 == 0) {
  73.                     printf(" [ %d]", j);
  74.                 }
  75.                 else {
  76.                     printf("  [%d]", j);
  77.                 }
  78.                 prev = true;
  79.             }
  80.             else {
  81.                 if (!prev)
  82.                     printf(" ");
  83.                 else {
  84.                     prev = false;
  85.                 }
  86.                 printf("  %d", j);
  87.             }
  88.         }
  89.         printf("\n");
  90.     }
  91.  
  92.    
  93.  
  94.     return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement