当前位置:网站首页>第16周OJ实践1 计算该日在本年中是第几天
第16周OJ实践1 计算该日在本年中是第几天
2022-07-26 16:45:00 【51CTO】
问题及代码:
Problem A: C语言习题 计算该日在本年中是第几天
Description
定义一个结构体变量(包括年、月、日)。编写一个函数days,由主函数将年、月、日传递给函数days,计算出该日在本年中是第几天并将结果传回主函数输出。
Input
年月日
Output
当年第几天
Sample Input
Sample Output
运行结果:

知识点总结:可以定义一个数组,先将二月按28天计入,最后再判断是否为闰月,若是,加一天,要记得同时判断已在二月之后。
闰年的判断方法
公历闰年判定遵循的规律为:
四年一闰,百年不闰,四百年再闰。
公历闰年的简单计算方法(符合以下条件之一的年份即为闰年)
1。能被4整除而不能被100整除。
2。能被400整除。
学习心得:再次遇到了关于闰年的问题,闰年的判断方法为(n%4==0&&n%100!=0)||(n%400==0)
边栏推荐
- [daily3] vgg16 learning
- 2 - configuration and use of routes
- Pyqt5 rapid development and practice 3.2 introduction to layout management and 3.3 practical application of QT Designer
- Stand aside with four and five rear cameras, LG or push the 16 rear camera mobile phone!
- 使用 Dired 快速移动文件
- 【开发教程9】疯壳·ARM功能手机-I2C教程
- Reuse idea through registry
- Win11 how to close a shared folder
- leetcode:1206. 设计跳表【跳表板子】
- After Oracle creates a table partition, the partition is not given during the query, but the value specified for the partition field will be automatically queried according to the partition?
猜你喜欢

About the difference between BigDecimal conversion string toengineeringstring, toplainstring and toString

Realizing DDD based on ABP -- related concepts of DDD

How does the data link layer transmit data

Redis persistence - detailed analysis of RDB source code | nanny level analysis! The most complete network

My meeting of OA project (meeting seating & submission for approval)
![37. [categories of overloaded operators]](/img/67/b821270079589c53b9c38b0ca033ac.png)
37. [categories of overloaded operators]

Eureka Registry - from entry to application

2019 popularization group summary

浅谈云原生边缘计算框架演进

Advantages of time series database and traditional database
随机推荐
Stand aside with four and five rear cameras, LG or push the 16 rear camera mobile phone!
【Express接收Get、Post、路由请求参数】
Create MySQL function: access denied; you need (at least one of) the SUPER privilege(s) for this operation
MySQL foundation - basic database operation
带你一分钟了解对称加密和非对称加密
37.【重载运算符的类别】
Is it safe for Guosen Securities to open an account? How can I find the account manager
Detailed explanation of openwrt's feeds.conf.default
Pack tricks
Add 5g and AI, oppo announced to invest 10billion R & D funds next year!
API for sellers -- description of the return value of adding baby API to Taobao / tmall sellers' stores
Stop supporting Huawei! Signing 640billion 5g orders in Germany and 270billion 5g orders in the Middle East is pure nonsense!
There are six ways to help you deal with the simpledateformat class, which is not a thread safety problem
正则表达式
VIM visualization mode and its usage
Redis persistence - detailed analysis of RDB source code | nanny level analysis! The most complete network
OpenWrt之feeds.conf.default详解
In depth exploration of ribbon load balancing
Detailed explanation of tcpdump command
Recurrence of historical loopholes in ThinkPHP