SHARE
TWEET

Untitled

a guest Dec 8th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.  
  5.     int day = 1, month = 1, year = 1; // i yakum ruzay, harruza ziyod kadan megirem
  6.     int limits[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; // soli 0001 soli leap nestay baroi hami mo fevrala 28 meknem.
  7.     // limits da ma 0 dobavit kadm ki moho nomeroi tughrira bgiran 1,2,...,12, Agane yanvar 0 meshid fevral 1, dekabr 11.
  8.  
  9.     string s;
  10.     cin >> s;
  11.     // inputa da string soxranit mekem, variabloi oxday, oxmonth, oxyear iyo oxiron ruza mefahmonan.
  12.     int oxday = stoi( s.substr(0,2)), oxmonth = stoi(s.substr(2,2)), oxyear = stoi(s.substr(4,4)); // oxironruza mefahmonan.
  13.  
  14.     int answer = 0; // i javobi savoli, yane chandruz guzashtay.
  15.     while( true ){
  16.         ///////////////////////////////////////////////////////
  17.         if( year > oxyear )
  18.             break;
  19.         if( year == oxyear && month > oxmonth )
  20.             break;
  21.         if( year == oxyear && month == oxmonth && day > oxday )
  22.             break;
  23.         // i 3 if-i bologi baroi bfahmem ki to ruzi guftagisha omadem yo ne.
  24.         // Agar omada boshem pas boyad diga davom nadihem...
  25.         /////////////////////////////////////////////////////////
  26.         answer++;
  27.         if( limits[month] < day ){ // yane agar mohi nav faro rasid....
  28.             if( month == 12 ){ // yane agar mohi dekabr tamom shid soli nav meshava ku...
  29.                 year++;
  30.                 if( (year % 400 == 0) ||(year % 4 == 0 && year % 100 != 0)){ // yane agar soli nav leap year bosha fevrala 29 knem.
  31.                     limits[2] = 29;
  32.                 }else{//agane soli nav leap year nestay.
  33.                     limits[2] = 28;
  34.                 }
  35.             }
  36.            
  37.             day = 1; // mohi nav ay yak sar meshava baroi hami ruza 1-um meknem.
  38.  
  39.             month++; // mohi nav faro rasid ku, baroi hami mo boyad mohi peshtarara alish knem,
  40.             if( month == 13 ) month = 1;
  41.         }
  42.         day++;
  43.     }
  44.     cout << answer;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top