9 条题解
-
3刘语辰 LV 6 @ 2019-09-06 11:45:26
a = int(input()) #获取年份 b = int((a % 4 == 0 and a % 100 != 0) or a % 400 == 0)+28 #计算二月长度 print([-1,31,b,31,30,31,30,31,31,30,31,30,31][int(input())]) #从得到的这年月份长度数组(部分打表)中抽取相关月并直接输出
过于暴力,不建议参考此答案。
-
22021-02-10 16:44:18@
#include <iostream> #include <cstdio> using namespace std; int main() { int year,leap,month;cin>>year>>month; if(year%4==0&&year%100!=0||year%400==0) leap=1; else leap=0; int a[13]={31,28+leap,31,30,31,30,31,31,30,31,30,31}; int i=month; if(i) cout<<a[i-1]; return 0; }
-
12020-09-16 22:47:57@
#python3
a=float(input()) b=float(input()) if b==1: print(31) elif b==3: print(31) elif b==4: print(30) elif b==5: print(31) elif b==6: print(30) elif b==7: print(31) elif b==8: print(31) elif b==9: print(30) elif b==10: print(31) elif b==11: print(30) elif b==12: print(31) elif b==2: if a%4==0 and a%100!=0: print(29) elif a%400==0: print(29) else: print(28)
-
12020-09-14 23:11:36@
y=int(input())
m=int(input())
if m==1 or m==3 or m==5 or m==7 or m==8 or m==10 or m==12:
c=31
elif m==2:
c=28
else:
c=30
if y%100==0:
if y%400==0 and m==2:
c=29
elif y%4==0 and m==2 :
c=29
print(int(c)) -
12019-03-23 21:13:38@
x=float(input()) y=float(input()) if y in [1,3,5,7,8,10,12]: print(31) elif y in [4,6,9,11]: print(30) elif y==2 and x%400==0: print(29) elif y==2 and x%4==0 and x%100!=0: print(29) else: print(28)
中规中矩
-
02024-06-17 18:13:17@
#include <stdio.h>
int lunarf(int a);
int monthf(int month);int main()
{
int lunar,type,month,year;
scanf("%d",&year);
scanf("%d",&month);
lunar = lunarf(year);
type = monthf(month);
//printf("%d",lunar);
//printf("%d",month);
if(type==2)
{
if(lunar==1)
{
printf("29");
}
else
{
printf("28");
}
return 0;
}
else
{
if(type==1)
{
printf("31");
}
else
{
printf("30");
}
}
return 0;
}int lunarf(int a)
{
int b;
b=0;
if(a % 4 == 0)
{
if(a % 100 != 0)
{
b=1;
}
else
{
if(a%400==0)
{
b=1;
}
}
}
else
b=0;
return b;
}int monthf(int month)
{
int ckpoint,i;
ckpoint=0;
int months[]={1,3,5,7,8,10,12};
int months1[]={2,4,6,9,11,11,11};
for(i = 0;i <= 6;i = i + 1){
if(month == months[i])
{
ckpoint=1;
}
else
{
if(month == 2)
{
ckpoint=2;
break;
}
else
{
if(month==months1[i])
{
ckpoint=3;
}
}
}
}
return ckpoint;
} -
02022-04-07 08:21:55@
#include <bits/stdc++.h>
using namespace std;
int v[13]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
int a,b;
cin>>a>>b;
if(a%4==0&&b==2&&a%100!=0||a%400==0&&b==2)
{
cout<<29;
return 0;
}
cout<<v[b-1];
return 0;
} -
02021-01-26 19:01:46@
#include <bits/stdc++.h>
using namespace std;
int main()
{
int year,month, leap, day;
cin>>year>>month;
int r4=year%4;
int r100=year%100;
int r400=year%400;
if(r4==0)
if(r100==0)
if(r400==0)
leap=1;
else
leap=0;
else
leap=1;
else
leap=0;
if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
day=31;
else
if(month==2)
day=28+leap;
else
day=30;
cout<<day<<endl;
return 0;
}有那么点累赘。。
-
02019-03-22 13:25:11@
a=int(input())
b=int(input())
if((b==1)or(b==3)or(b==5)or(b==7)or(b==8)or(b==10)or(b==12)):
print("31")
elif(b==2):
if(((a%100!=0)and(a%4==0))or((a%100==0)and(a%400==0))):
print("29")
else:
print("28")
else:
print("30")
- 1
信息
- ID
- 1001
- 难度
- 8
- 分类
- (无)
- 标签
- (无)
- 递交数
- 2643
- 已通过
- 364
- 通过率
- 14%
- 被复制
- 5
- 上传者