C language written in the program of the perpetual calendar system how to calculate the day of the w

Updated on vogue 2024-03-26
6 answers
  1. Anonymous users2024-02-07

    I encapsulated the fetch method into a function called week.,His three parameters are year, month and day.,In it, it will print out the day of the week.,I don't understand the place to leave me a message.。

    #include

    #include

    voidweek(int

    year,int

    month,int

    day)tm

    tmtime

    time_t

    ttime;

    year-1900;

    month-

    day;ttime

    mktime(&tmtime);

    intweek

    localtime(&ttime)->tm_wday;

    ifweek

    printf("%dy",year,month,day,week);

    elseprintf("%dy",year,month,day);

    voidmain()

    week(2010,11,1);

  2. Anonymous users2024-02-06

    1. First of all, it is necessary to determine whether a year is a leap year or a common year, and use a subprogram to do it.

    2. Then start writing the main program, first use scanf to get a year.

    3. Use printf to print it out in cmd after judging whether the year is a common year or a leap year.

    4. After the writing is completed, press F5 under the Notepad++ interface to pop up the input box.

    5、cmd /k gcc -o "$(current_directory)\$name_part).exe""$(full_current_path)" &&cls &&"$(current_directory)\$name_part).exe" & pause & exit。

    Run after the input box is entered.

    6. Click Run, cmd will pop up, enter the year in it and press Enter to complete.

  3. Anonymous users2024-02-05

    #include""

    #include""

    main( )

    printf("c Language Simple Perpetual Calendar");Print the title doprintf("***n");

    printf("");

    printf("Do you want to continue (y n)?");

    scanf("%c",&yn);

    scanf("%c",&yn);//

    while(yn=='y' ||yn=='y');}

  4. Anonymous users2024-02-04

    This week difference refers to the difference between the day of the week on the 1st of each month and the day of the week on January 1 of the current year, which is not calculated across years, but the difference between the day of the week on the first day of the month of the same year and the day of January 1.

    The program is: case 5: dm=1+m2; month=31; break;

    This means that if January 1 is a Saturday, then May 1 of the same year is Saturday + (1+m2).

    If it is a leap year, m2 = 1, otherwise m2 = 0.

    The year 2000 is a leap year, so May 1, 2000 is a Saturday (1 1) Monday.

    The nth day of the month is the value of 7 on the first day of the week (n-1)).

    So, May 4th is Thursday, Saturday (1 1) (4 1)) 7 4.

  5. Anonymous users2024-02-03

    The perpetual calendar counts the day of the week.

    Just say the year, month, and day of the Common Era, and you can immediately calculate the day of the week.

    Just calculate the day, month, year. The remainder of the three added up divided by seven is the day of the week (if the remainder is three, it is Wednesday).

    Calculation of the day: The simplest of the day is itself, which is the number of the number.

    Month**Calculation: Month** is also very simple, there are twelve numbers below: 1 4 4 7 2 5 7 3 6 1 4 6, which represent ** for each month from January to December.

    For example, the ** in September is 6(According to the guest, he used the method of reverse deduction to calculate the 12 months**, that is, he knew that the day of the week was the day of the week in a certain month, and in turn calculated the month**.) )

    Calculation of year**: year** is relatively complicated, first remember that the corresponding year of 2000 is 4, which is the basic**, just keep it in mind.

    If it is greater than 2000, such as 2010, then the corresponding year** is (2010 2000) 4=2......2. Subtract 2 times the quotient plus the remainder with base **4 and add 1That is, 4 2 2 + 2 + 1 = 3, then the corresponding year ** of 2010 is 3If there is no remainder, i.e., a run-year, then the 1 after the remainder does not need to be added.

    For example, in 2008, the corresponding year** is 0

    If it is less than 2000, e.g. 1991, then the corresponding year** is (2000 1991) 4=2......1. Subtract the remainder with the quotient of base number **4 plus 2 times. That is, 4+2 2 1=7, then the corresponding year ** of 1991 is 7

    Remember 1 special case, that is, from March to December of the year, 1

    October 1, 1949.

    then (2000, 1949) 4=12......3, then 4 + 2 12 3 = 25, the calculation result of year ** is 25, plus **1 in October, plus **1 of day, equal to 27Divide by seven for the remainder of 6, and the day is Saturday.

  6. Anonymous users2024-02-02

    I can help you with this.

Related questions
7 answers2024-03-26

Look"Malloc", there is an article on the first page that is clearly written.

3 answers2024-03-26

Heada and headb are both singly linked lists with leading nodes. In this algorithm, we delete the common elements from the ith element in the heada linked list, and then insert the single-linked list heada before the jth element of the headb. >>>More

8 answers2024-03-26

Method steps.

Open VS2012 - File - New - Project. >>>More

8 answers2024-03-26

The semicolon is the sign of the end of the statement, but the semicolon is not used after the loop, if, and subfunctions such as long long a (int b), and everything else is used, but two semicolons cannot be added, although it will not cause an error, but it may affect the result.