Korotkodul

N1. Шаг в будущее

Oct 29th, 2021 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. void co(vector <int> v){
  6.     for (auto &x: v) cout<<x<<' ';
  7.     cout<<'\n';
  8. }
  9. vector <int> cal = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  10. //31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  11. int dst = 0;
  12. int day = -1, month = -1, year = -1, fst = -1;//first jan
  13. void dist(){
  14.     for (int i = 1;i<=12;++i){
  15.         cout<<"mnth = "<<i<<'\n';
  16.         if (i == month){
  17.             cout<<" += "<<day<<'\n';
  18.             dst += day;
  19.             break;
  20.         }
  21.         else{
  22.             cout<<"+= "<<cal[i]<<'\n';
  23.             dst += cal[i];
  24.         }
  25.     }
  26. }
  27. int main()
  28. {
  29.  
  30.     cin>>day>>month>> year>>fst;
  31.     if (year % 4 == 0 && year % 100 != 0) {
  32.             cal[2] = 29;
  33.             //cal[4] = 31;
  34.     }
  35.     else if (year % 4 == 0 && year % 100 == 0 && year % 400 == 0){
  36.         cal[2] = 29;
  37.     }
  38.     dist();
  39.     cout<<"dst = "<<dst<<'\n';
  40.     int ans;
  41.     ans = ( fst + dst - 1) % 7;
  42.     if (ans == 0) ans = 7;
  43.     cout<<ans;
  44. }
  45. /*
  46. 29 02 2016 5
  47. 1+
  48. 01 01 2010 5
  49. 5+
  50. 31 12 2010 5
  51. 5 +
  52. 30 12 2010 5
  53. 4+
  54. 29 12 2010 5
  55. 3+
  56. 28 12 2010 5
  57. 2+
  58. 27 12 2010 5
  59. 1+
  60. 26 12 2010 5
  61. 7+
  62. 26 12 2016 5
  63. 1+
  64. 26 12 2000 6
  65. 2+
  66. 26 12 1900 1
  67. 3+
  68. */
  69. //07 01 312 01
  70. //7+
  71.  
Add Comment
Please, Sign In to add comment