当前位置:网站首页>Calculation days ()
Calculation days ()
2022-06-22 08:10:00 【Study hard 867】
This problem requires writing a program to calculate the day of a certain month in a certain year .
Input format :
The input is formatted in one line “yyyy/mm/dd”( namely “ year / month / Japan ”) Give the date . Be careful : The criterion of leap year is that the year can be 4 Divide but not be 100 to be divisible by 、 Or can be 400 to be divisible by . Leap year's 2 Monthly 29 God .
Output format :
In one line, the output date is the day of the year .
sample input 1:
2009/03/02
sample output 1:
61
sample input 2:
2000/03/02
sample output 2:
62Code :
#include <stdio.h>
int main(){
int a[12]= {31,29,31,30,31,30,31,31,30,31,30,31};
int b[12]= {31,28,31,30,31,30,31,31,30,31,30,31};
int years,month,day,sum=0;
scanf("%d/%2d/%2d",&years,&month,&day);
int flag=0;
int i;
if((years%4==0&&years%100!=0)||years%400==0) {
flag=1;
}
if(flag==1) {
for(i=0; i<month-1; i++) {
sum=sum+a[i];
}
for(i=0; i<day; i++) {
sum=sum+1;
}
}
else {
for(i=0; i<month-1; i++) {
sum=sum+b[i];
}
for(i=0; i<day; i++) {
sum=sum+1;
}
}
printf("%d",sum);
}边栏推荐
- [Oracle database] mammy tutorial day13 date function
- Microsoft Remote Desktop 10.7.6 official
- Example of QT combox
- Model electricity experiment -- Experiment 1 transistor common emitter single transistor amplifier
- How to create an index
- EURUSD,H1: invalid lots amount for OrderSend function
- Summary of basic knowledge of Oracle database SQL statements I: Data Definition Language (DDL)
- OSI and tcp/ip
- Collections and arrays
- KVO summary
猜你喜欢

LNMP environment setup

【Oracle 数据库】奶妈式教程 day14 转换函数
![[Oracle database] mammy tutorial Day11 numerical function](/img/75/6a4340a7e9c6ee5f75a95bb3b6747f.png)
[Oracle database] mammy tutorial Day11 numerical function
![[Oracle database] mammy tutorial Day12 character function](/img/77/3b3aa643b0266e709019399b17bb93.png)
[Oracle database] mammy tutorial Day12 character function

Example of QT combox

MySQL view

Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - special identification of the K line on the chart

2022年CIO面临的七大挑战及应对方法

Failed to access the ES installed on Tencent ECs, but the solution to accessing the ES successfully on the server

0基础自学stm32(野火)——什么是寄存器?
随机推荐
Using KDJ metrics on MT4
Some problems caused by null data in MySQL
0基础自学stm32(野火)——什么是寄存器?
The significance of code coverage testing to programming white and its application
歪门邪道之解决首屏图片加载闪烁问题
MySQL avoids the method of repeatedly inserting records (ignore, replace, on duplicate key update)
Mystery of power bank
Design skills of common table structure in database design
Mt4/mql4 getting started to mastering EA tutorial lesson 5 - common functions of MQL language (V) - common functions of account information
Oracle execution plan analysis
C#实现语音朗读功能
Qt 错误提示1: invalid use of incomplete type ‘***‘
模电实验——实验一 晶体管共射极单管放大器
Node red sends wechat official account message (template message)
How to design the dead shot, the best and eye-catching performance of the watch Vanguard
Thoughts on the construction of data analysis platform for small and medium-sized enterprises (I)
MySQL delete from and subquery as conditions
0 basic self-study STM32 (wildfire) -- what is a register?
Svn submits subfolder questions
《守望先锋》阵亡镜头、全场最佳和亮眼表现是如何设计