שאלה: חישוב תאריכים

dor_ian

New member
שאלה: חישוב תאריכים

איך יודעים מתי שנה מעוברת? ומתי חודש נגמר? אין יותר שיממון למתכנת לכתוב class date נראה לי. בעעעעעע תודה מראש
 

DNile

New member
מתי חודש נגמר:

עקרונית, יש כמה דרכים לחשב מתי חודש נגמר:
1. Thirty days has September, April, June and November, All the rest have thirty one, Excepting February, fun! And that has twenty eight days clear, And twenty nine in a Leap Year! 2. Thirty days has September, April, June and November. All the rest have 31 except February which has 4 and 24, 'til Leap Year gives it one day more. 3. Thirty days hath September, April, June, and November; all the rest have thirty-one, except for February alone. February has twenty-eight days clear, and twenty-nine in each Leap Year. 4. Thirty days hath September, April, June, and November; February has twenty-eight alone, All the rest have thirty-one, Excepting Leap-Year, that's the time When February's days are twenty-nine. 5. Thirty days hath Juvember, Apples, Noon and No Wonder, All the rest have Peanut Butter, Except my Grandma And she has a little red tricycle.​
מתי יש שענה מעוברת?Leap year כדברי החמשירים? כשהשנה מתחלקת ב400 - כן. כשהשנה מתחלקת ב100, אך לא ב400 - לא. כשהשנה מתחלקת ב4, אך לא ב100(למעט המקרה של ה400) - כן.
 

dor_ian

New member
זהו, אני עוזב את המקצוע

סתם תודה רבה. תבדוק רגע את הבית האחרון. אמור להיות שם NOVEMBER ?
 

eyalbd

New member
בבקשה

int is_leap_year(int y) { return ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0); } int days_in_month(int y, int m) { static const int month_days[] ={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; return (m == 2 && _is_leap_year(y)) ? 29 : month_days[m]; }​
 

DNile

New member
אני ממש ממש ממש מפחד

לראות איך היית מגיב למישהו שהיה שואל פה: "איך מנגבים את התחת"...
 

eyalbd

New member
ותתפלא - גם ניגוב תחת צריך ללמד

כשיהיו לך זאטוטים משלך תראה שכן...
 
למעלה