隐藏行号 复制代码 判断奇偶数
  1. //判断是否为奇数和偶数
  2. import java.util.Scanner;
  3. public class jsos {
  4. public static void main(String[] args) {
  5. System.out.print("请输入一个数字:");
  6. Scanner i=new Scanner(System.in);
  7. int    num=i.nextInt();
  8. if (num<=0) {
  9. System.out.print("请输入正整数!");
  10. }else if (num%2==0) {
  11. System.out.print("“"+num+"”"+"为偶数!");
  12. }else {
  13. System.out.print("“"+num+"”"+"为奇数!");
  14. }
  15. }
  16. }