键盘输入10个正整数,先打印输出奇数,再输出偶数

package com.shuzu;


import java.util.Scanner;


//1.编写程序,键盘输入10个正整数,先打印输出奇数,再输出偶数。(用数组)
//第一題:
public class Zuoye1012 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] a = new int[10];
int e = a.length;
for (int i = 0; i < e; i++) {
System.out.println("請輸入第" + (i + 1) + "个数");
a[i] = sc.nextInt();
}
System.out.print("偶数为:");
for(int i=0;i if(a[i]%2==0){
System.out.println(a[i]);
}
}
System.out.println();
System.out.print("奇数为:");
for(int i=0;i if(a[i]%2!=0){
System.out.println(a[i]);
}
}

你可能感兴趣的:(案例)