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 print the calendar of a certain month in a certain year in C language

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "how to print the calendar of a certain month in a certain year in C language". In the daily operation, I believe that many people have doubts about how to print the calendar of a certain month in a certain year in C language. The editor consulted all kinds of data and sorted out a simple and easy-to-use operation method. I hope it will be helpful for you to answer the doubt of "how to print a calendar of a month in a certain year in C language". Next, please follow the editor to study!

General ideas:

① determines whether the year entered is a leap year.

② calculates that the first day of the input month is the day of the year.

③ calculates what day the first day of the input month is.

④ output.

Use in combination with code: # define _ CRT_SECURE_NO_WARNINGS 1#include int main () {int arr1 [] = {0pence 31je 28je 31je 30je 31je 31pr 31pr 31pr 31}; int I = 0; int year = 0; int month = 0; int days = 0; int week = 0 year / scanf ("% d% d", & year, & month) If ((year% 4 = = 0 & & year% 100! = 0) | | (year% 400 = = 0) / / determine whether it is a leap year {arr1 [2] = 29 days++ / 29 days of February in a leap year} for (I = 0; I < month; +) {days+ = arr1 [I]; / calculate the number of days of the year} days++ / / the first day of the month should also be counted in / / apply the formula for calculating the day of the week week = (year-1 + (year-1) / 4-(year-1) / 100 + (year-1) / 400 + days)% 7; printf ("Day one, two, three, four, five\ n"); / / header int arr2 [50] = {0}; for (I = 0) I < week; iTunes +) {printf (""); / / the integer array cannot store spaces, so print the spaces directly} arr2 [week] = 1; for (I = week + 1; I

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

Development

Wechat

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

12
Report