출제 링크 : https://www.acmicpc.net/problem/2753
2753번: 윤년
연도가 주어졌을 때, 윤년이면 1, 아니면 0을 출력하는 프로그램을 작성하시오. 윤년은 연도가 4의 배수이면서, 100의 배수가 아닐 때 또는 400의 배수일 때이다. 예를 들어, 2012년은 4의 배수이면서
www.acmicpc.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Solution
{
class Program
{
static void Main(string[] args)
{
int year = int.Parse(Console.ReadLine());
if(year%4 == 0)
{
if(year%100 != 0 || year % 400 == 0)
{
Console.WriteLine(1);
}
else
{
Console.WriteLine(0);
}
}
else
{
Console.WriteLine(0);
}
}
}
}
'Baekjoon 문제풀이' 카테고리의 다른 글
[Baekjoon 2단계(5)] 2884번 : 알람 시계 (0) | 2021.08.31 |
---|---|
[Baekjoon 2단계(4)] 14681번 : 사분면 고르기 (0) | 2021.08.31 |
[Baekjoon 2단계(2)] 9498번 : 시험 성적 (0) | 2021.08.31 |
[Baekjoon 2단계(1)] 1330번 : 두 수 비교하기 (0) | 2021.08.31 |
[Baekjoon 1단계(11)] 2588번 : 곱셈 (0) | 2021.08.31 |