1 solutions
-
0
C :
#include <stdio.h> long long a, b, t; int main(void) { scanf("%lld %lld", &a, &b); printf("%lld-%lld-", a, b); if (b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12) { printf("31"); } else if (b == 4 || b == 6 || b == 9 || b == 11) { printf("30"); } else { if (a % 400 == 0 || (a % 100 != 0 && a % 4 == 0)) { printf("29"); } else { printf("28"); } } printf("\n"); return 0; }C++ :
#include<iostream> using namespace std; int main() { int a,b,c; cin>>a>>b; if ((b==1)||(b==3)||(b==5)||(b==7)||(b==8)||(b==10)||(b==12)) c=31; if ((b==4)||(b==6)||(b==9)||(b==11)) c=30; if (b==2) { if ((a%4!=0)||(a%100==0&&a%400!=0)) c=28; if ((a%100!=0&&a%4==0)||(a%100==0&&a%400==0)) c=29; } cout<<a<<"-"<<b<<"-"<<c<<endl; return 0; }Pascal :
var a,b,c:longint; begin readln(a,b); case b of 1,3,5,7,8,10,12:c:=31; 4,6,9,11:c:=30; 2:if ((a mod 100<>0) and (a mod 4=0)) or (a mod 400=0) then c:=29 else c:=28; end; writeln(a,'-',b,'-',c); end.Python :
# coding=utf-8 s = input(). split() a = int(s[0]) b = int(s[1]) print(a, b, '', sep = '-', end = '') 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 == 4 or b == 6 or b == 9 or b == 11 : print(30) else : if (not a % 400) or (a % 100 and (not a % 4)) : print(29) else : print(28)
- 1
Information
- ID
- 17701
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By