文章

28

粉丝

0

获赞

98

访问

3.6k

头像
这是第几天? 题解:如下
P1542 云南大学/暨南大学机试题
发布于2025年3月18日 09:22
阅读数 126

#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int run(int year){
if((year%4==0&&year%100!=0)||year%400==0)
	return 1;
	return 0;

}
int main(){
int x[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int year,month,day,total=0;
scanf("%d-%d-%d",&year,&month,&day);
if(run(year)){
x[2]++;
}  //判断是否为闰年;
for(int i=1;i<month;i++)
	total+=x[i];
	total+=day;
	cout<<total;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发