c++ - Having problems with detecting leap year -
Again AHI, thanks everyone for help in my previous problem.
However, now I have to face another problem
int main () {int inputSeconds, seconds, minutes, hours, days, years; Int remaining balance; Int current_year = 1970; Int current_month = 1; Int current_day = 1; Const int standard_year = 365; Const int leap_year = 366; Boole leap year; Int Lepscunter; // The closest leap year since 1972, the counter is set for 2 seats & lt; & Lt; "Welcome to Epoch Time / Data Converter" & lt; & Lt; Endl; Cout & lt; & Lt; "Enter the number of seconds from midnight January 1, 1970:"; Cin & gt; & Gt; InputSeconds; // To change the number of years in a few days to convert the number of days already = inputSeconds / (60 * 60 * 24); Balance balance = input SEK% (60 * 60 * 24); Cout & lt; & Lt; Day & lt; & Lt; Endl; // Set the current year (while (! (Day & lt; 365)) {if (leapcounter == 3) {current_year ++; day - = leap_yure; LeapYear = true; Leapcounter = 0;} and {current_year ++ ; Days = standard_eur; leapcounter ++; LeapYear = false;}} // Check whether the current year is leap year or not ((current_yure% 4 == 0) & amp; (current_yure% 100 == 0). | (Current_yyyre% 400 == 0)) leapYear = true; second leap year = false; cout & lt; current_yure & lt; "left day:" }
This output I do not seem to find a leap year, I have tried 1972, 2004, 2008 and 2012.
I am unable to understand the problem with it and hope that you are on my problem Thank you in advance.
current_year The reasoning for deciding a leap year is a bit more complicated. if ((current_year% 4 == 0)) {if ((current_year% 100 == 0)) < P> {If ((current_year% 400 == 0)) {leapYear = true; } And {leapYear = false; }} And {leapYear = true; }} And {leapYear = false; } On further thinking, this argument can be simplified:
leapyear = ((current_year% 400) == 0 || ((Current_year% 4) == 0 & amp; (current_year% 100)! = 0)); In addition, you need to get started with leapcounter to 2 because the first day of the day 1 Corresponds to 1970 - 2 years since the last leap year.
Comments
Post a Comment