奇偶性 JAVA語言實驗 SDUT OJ1583

奇偶性

Time Limit: 1000 ms Memory Limit: 32768 KiB

Problem Description

    判斷輸入的數據的奇偶性。

Input

    輸入數據第一行是一個正整數N,接下來N行,每行一個正整數。

Output

    對於每個輸入數據輸出一行,如果是奇數則輸出odd,否則輸出even。

Sample Input

3
2
4
5

Sample Output

even
even
odd
import java.util.Scanner;
public class Main 
{
	public static void main(String args[])
	{
		Scanner reader = new Scanner(System.in);
		int N, x;
		N = reader.nextInt();
		while(N-- > 0)
		{
			x = reader.nextInt();
			if(x % 2 == 1)
			{
				System.out.println("odd");
			}
			else
			{
				System.out.println("even");
			}
		}
		reader.close();
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章