728x90

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int getLeapYear(int year) { | |
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) { | |
return 1; | |
} | |
return 0; | |
} | |
int main(void) { | |
ios::sync_with_stdio(false), cin.tie(nullptr); | |
int year; | |
cin >> year; | |
cout << getLeapYear(year); | |
} | |
// Authored by : wogha95 | |
// Co-authored by : BaaaaaaaaaaarkingDog | |
// http://boj.kr/5306be11066640fb96fa672ccd15b40c | |
// #include <bits/stdc++.h> | |
// using namespace std; | |
// int main(void) { | |
// ios::sync_with_stdio(0); | |
// cin.tie(0); | |
// int year; | |
// cin >> year; | |
// if (year % 4 == 0) { | |
// // 4의 배수이면서 400의 배수 | |
// if (year % 400 == 0) cout << 1; | |
// // 4의 배수이면서 100의 배수 | |
// else if (year % 100 == 0) | |
// cout << 0; | |
// // 4의 배수이면서 100, 400의 배수가 아닌 수 | |
// else | |
// cout << 1; | |
// } | |
// // 4의 배수가 아닌 수 | |
// else | |
// cout << 0; | |
// } |
'Algorithm > C&C++' 카테고리의 다른 글
백준 2490번: 윷놀이(c/c++, c/cpp) (0) | 2021.10.05 |
---|---|
백준 2480번: 주사위 세개(c/c++, c/cpp) (0) | 2021.09.29 |
백준 1000번: A+B(c++) (0) | 2021.09.27 |
백준 2752번: 세수정렬 c++(cpp) (0) | 2021.09.06 |
백준 10871번: X보다 작은 수 c++(cpp) (0) | 2021.09.06 |