[BAEKJOON] 백준 10480: Oddities (C#)

2024. 8. 7. 09:35IT/BaekJoon

문제 링크

https://www.acmicpc.net/problem/10480

 

 

문제

Some numbers are just, well, odd. For example, the number 3 is odd, because it is not a multiple of two. Numbers that are a multiple of two are not odd, they are even. More precisely, if a number n can be expressed as n = 2 ∗ k for some integer k, then n is even. For example, 6 = 2 ∗ 3 is even.

Some people get confused about whether numbers are odd or even. To see a common example, do an internet search for the query “is zero even or odd?” (Don’t search for this now! You have a problem to solve!)

Write a program to help these confused people.

 

 

입력

Input begins with an integer 1 ≤ n ≤ 20 on a line by itself, indicating the number of test cases that follow. Each of the following n lines contain a test case consisting of a single integer −10 ≤ x ≤ 10.

 

 

출력

For each x, print either ‘x is odd’ or ‘x is even’ depending on whether x is odd or even.

 

 

 

통과한 답안

namespace _10480
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            for (int i = 0; i < N; i++)
            {
                int num = int.Parse(Console.ReadLine());
                if (num % 2 == 0)
                {
                    Console.WriteLine($"{num} is even");
                }
                else
                {
                    Console.WriteLine($"{num} is odd");
                }
            }
        }
    }
}

 

n개의 테스트가 주어지고, 각 테스트에 주어진 숫자가 odd(홀수)인지 even(짝수)인지 판단하는 문제이다.