awsmpshk

Untitled

Dec 23rd, 2019
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. struct time {
  8. string cur_time;
  9. string showTime() {
  10. cout << cur_time << endl;
  11. }
  12. int takeDays() {
  13. int a[2];
  14. a[0] = cur_time[0] - '0';
  15. a[1] = cur_time[1] - '0';
  16. return a[0] * 10 + a[1];
  17. }
  18. int takeMonths() {
  19. int a[2];
  20. a[0] = cur_time[4] - '0';
  21. a[1] = cur_time[5] - '0';
  22. return a[0] * 10 + a[1];
  23. }
  24. int takeYears() {
  25. int a[4];
  26. a[0] = cur_time[8] - '0';
  27. a[1] = cur_time[9] - '0';
  28. a[2] = cur_time[10] - '0';
  29. a[3] = cur_time[11] - '0';
  30. return a[0] * 1000 + a[1] * 100 + a[2] * 10 + a[3];
  31. }
  32. };
  33.  
  34. int main() {
  35. time t1;
  36. getline(cin, t1.cur_time);
  37. if (t1.takeDays() == 1) {
  38. switch (t1.takeMonths()) {
  39. case 1:
  40. cout << "31, 12, " << t1.takeYears() - 1;
  41. break;
  42. case 2:
  43. cout << "31, " << t1.takeMonths() - 1 << ", " << t1.takeYears();
  44. break;
  45. case 3:
  46. if (t1.takeYears() % 4 == 0 && t1.takeYears() % 100 != 0 || t1.takeYears() % 400 == 0) {
  47. cout << "29, " << t1.takeMonths() - 1 << ", " << t1.takeYears();
  48. }
  49. else cout << "28, " << t1.takeMonths() - 1 << ", " << t1.takeYears();
  50. break;
  51. case 4:
  52. cout << "31, 12, " << t1.takeYears() - 1;
  53. break;
  54. case 5:
  55. cout << "31, 12, " << t1.takeYears() - 1;
  56. break;
  57. case 6:
  58. cout << "31, 12, " << t1.takeYears() - 1;
  59. break;
  60. case 7:
  61. cout << "31, 12, " << t1.takeYears() - 1;
  62. break;
  63. case 8:
  64. cout << "31, 12, " << t1.takeYears() - 1;
  65. break;
  66. case 9:
  67. cout << "31, 12, " << t1.takeYears() - 1;
  68. break;
  69. case 10:
  70. cout << "31, 12, " << t1.takeYears() - 1;
  71. break;
  72. case 11:
  73. cout << "31, 12, " << t1.takeYears() - 1;
  74. break;
  75. case 12:
  76. cout << "31, 12, " << t1.takeYears() - 1;
  77. break;
  78. default:
  79. cout << t1.takeDays() - 1 << ", " << t1.takeMonths() << ", " << t1.takeYears();
  80. }
  81. }
  82. return 0;
  83. }
RAW Paste Data Copied