当前位置:网站首页>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;
边栏推荐
- Partial summary of 45 lectures on geek time MySQL
- Software engineering - personal assignment - question review and personal summary
- 2021 software university ranking crawler program
- 9. code generation
- 深度学习论文阅读目标检测篇(七)中文版:YOLOv4《Optimal Speed and Accuracy of Object Detection》
- 框架跳转导致定位失败的解决方法
- Using MySQL and Qt5 to develop takeout management system (I): environment configuration
- commonJS和ES6模块化的区别
- Pytorch build progression
- Whale conference provides digital upgrade scheme for the event site
猜你喜欢

百度小程序富文本解析工具bdParse

Autoregressive model of Lantern Festival

XSS cross site scripting attack

【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(一)

Section IV HQL execution process

力扣399【除法求值】【并查集】

20220623 getting started with Adobe Illustrator

Fast construction of neural network

phpcms手机站模块实现自定义伪静态设置

Koa_ mySQL_ Integration of TS
随机推荐
Whale conference one-stop intelligent conference system helps organizers realize digital conference management
Convert verification code image to tfrecord file
1.21 study gradient descent and normal equation
关于极客时间 | MySQL实战45讲的部分总结
torch. fft
ROS learning notes (5) -- Exploration of customized messages
1.20 study univariate linear regression
Exploration of webots and ROS joint simulation (II): model import
Pytorch neural network
Section IV HQL execution process
dedecms小程序插件正式上线,一键安装无需任何php或sql基础
phpcms小程序插件api接口升级到4.3(新增批量获取接口、搜索接口等)
Machine learning (Part 2)
Uniapp uses uparse to parse the content of the background rich text editor and modify the uparse style
框架跳转导致定位失败的解决方法
【云原生 | Kubernetes篇】深入万物基础-容器(五)
Drawing with MATLAB (2) -- color ring
phpcms小程序插件教程网站正式上线
Data warehouse (1) what is data warehouse and what are the characteristics of data warehouse
Speckle denoising method for ultrasonic image