Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report