Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Python to calculate what day a day is in that year

Shulou Source: shulou.com Published: 2022-06-01 11:22:16 10月02日 Update

This article introduces the relevant knowledge of "how to use Python to calculate what day is the first day of the year". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Write a program to calculate the number of days, and the user enters the year, month and day from the keyboard and outputs the date on the screen as the day of the year.

C code:

/ * the third day, the day of the year is calculated * / # include # include int main (void) {/ * parameters are year, month, day, number of days calculated, initial value of for cycle * / / * Note: days assigns an initial value of 0, does not assign a value, and the value of the variable is uncertain, which will lead to run collapse * / int year,month,day,days = 0meme I = 0fliint average_year [12] = {31meme28,31parentin 3130remiere 3130remiere 3130remiere 3130remit 31} / / usual year int leap_year [12] = {31pyrrine 29 pencils 31pence 30g 31pjre 30g 31pr 31pr 30g 31}; / / Leap year printf ("Please enter the date to be queried, for example: January 30th, 1993\ n"); scanf ("% d year% d month% d day", & year,&month,&day) / * A year that is divisible by 400or divisible by 100but is a leap year * / if (year% 400 = = 0 | | year% 4 = = 0 & & year% 100! = 0) {/ * the index value of the first element of the array is 0, adding up the first few months of the month month * / for

Tags: Input query date code days normal year error leap year AD content more knowledge results output practical learned and then elements upgrades parameters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Docker Microsoft MySQL