7-3 判断奇偶 (10分)

    科技2022-07-15  123

    7-3 判断奇偶 (10分) 输入一个整数,判断其奇偶性

    输入格式: x(整数)

    输出格式: x is even. (偶数) x is odd. (奇数)

    输入样例: 在这里给出一组输入。例如:

    4 输出样例: 在这里给出相应的输出。例如:

    4 is even. 作者 陈海宁 单位 成都信息工程大学 代码长度限制 16 KB 时间限制 400 ms 内存限制 64 MB Java (javac 1.8.0)

    import java.util.Scanner; public class Main{ public static void main(String args[]){ int x; Scanner scan = new Scanner(System.in); x=scan.nextInt(); if(x%2==0) System.out.println(x+" is even."); else System.out.println(x+" is odd."); } }

    其他题目

    Processed: 0.011, SQL: 8