1 条题解
-
0
C++ :
#include <iostream> #include <cstdio> using namespace std; int main() { int year,month; while(scanf("%d%d",&year,&month)==2) { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: cout<<31<<endl; break; case 4: case 6: case 9: case 11: cout<<30<<endl; break; default: //2月 if( (year%100 != 0 && year%4 == 0) || (year%400 == 0) ) { //如果是闰年,2月29天 cout<<29<<endl; } else { //如果是平年,2月28天 cout<<28<<endl; } break; } } }Pascal :
var x,y,d:longint; leap:boolean; begin while not eof do begin readln(x,y); if ((x mod 4=0)and(x mod 100<>0))or(x mod 400=0)then leap:=true else leap:=false; case y of 1,3,5,7,8,10,12:d:=31; 4,6,9,11:d:=30; 2:if leap then d:=29 else d:=28; end; writeln(d); end; readln; end.
- 1
信息
- ID
- 3528
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者