当前位置:网站首页>Programming training 7- date conversion problem
Programming training 7- date conversion problem
2022-06-26 08:59:00 【Parity nonconservative 4.0】
Test description
According to the following function prototype, use function programming to solve the following date conversion problem ( Ask to consider leap years ):
Enter the date of the year , Calculate and output the day of the year .
/* The functionality : For a given year, month and day , Calculate and return the day of the year it is
Function parameter : Integer variables year、month、day, Each represents the year 、 month 、 Japan
Function return value : The day of the year */
int DayofYear(int year, int month, int day);
Input
Input 3 It's an integer , Each represents the year 、 month 、 Japan , Use a space between two adjacent items .
Output
Output an integer , It means the day of the year .
Input example
2000 1 31
Output example
31
#include <stdio.h>
int DayofYear(int year, int month, int day)
{
int i,leap,n=0,a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
leap=(year%4==0&&year%100!=0)||year%400==0;
for(i=0;i<month-1;i++)
n=n+a[i];
if(month>2)
n=n+leap;
return n+day;
}
int main()
{
int n,year,month,day;
scanf("%d%d%d",&year,&month,&day);
n=DayofYear(year,month,day);
printf("%d",n);
return 0;
边栏推荐
- 1.Intro_ Math (white board derivation and reprint of station B)
- WBC learning notes (I): manually push WBC formula
- phpcms手机站模块实现自定义伪静态设置
- Slider verification - personal test (JD)
- 如何利用最少的钱,快速打开淘宝流量入口?
- Ultrasonic image segmentation
- ThreadLocal
- 唯品会工作实践 : Json的deserialization应用
- Implementation of ffmpeg audio and video player
- [resolved]setonnavigationitemselectedlistener() deprecated
猜你喜欢

Using MySQL and Qt5 to develop takeout management system (I): environment configuration

基于SSM的电脑商城

20220623 Adobe Illustrator入门

What are the conditions for Mitsubishi PLC to realize Ethernet wireless communication?

Partial summary of 45 lectures on geek time MySQL

Clion installation + MinGW configuration + opencv installation

Structure diagram of target detection network

Slider verification - personal test (JD)

WBC learning notes (I): manually push WBC formula

Bezier curve learning
随机推荐
Uniapp uses uparse to parse the content of the background rich text editor and modify the uparse style
Yolov5进阶之二安装labelImg
How to use leetcode
【IVI】15.1.2 系统稳定性优化篇(LMKD Ⅱ)PSI 压力失速信息
Some commands for remote work
在哪个软件上开户比较安全
Backward usage
Graduation thesis management system based on SSM
Selenium 搭建 Cookies池 绕过验证反爬登录
Yolov5进阶之五GPU环境搭建
Convert verification code image to tfrecord file
dedecms小程序插件正式上线,一键安装无需任何php或sql基础
QT_ AI
Computer mall based on SSM
Solution to the encoding problem encountered by the crawler when requesting get/post
torch. fft
keras_ Callback function summary
Summary of common instructions for arm assembly
Implementation of ffmpeg audio and video player
phpcms小程序插件4.0版正式上线