编写一个Java程序,计算一下1,2,…,9这9个数字可以组成多少个互不相同的、无重复数字的三位偶数。
package a; public class SanWeiOuShu { public static void main(String[] args) { String str="123456789"; String a,b,c; int sum=0; for (int i = 1; i < 9; i+=2) { a=str.substring(i,i+1); String str1 = str.replace(a,""); for (int j = 0; j < 8; j++) { b=str1.substring(j,j+1); String str2 = str1.replace(b, ""); for (int k = 0; k < 7; k++) { c=str2.substring(k,k+1); System.out.print(new Integer(c+b+a)+"\t"); sum+=1; } System.out.println(); } System.out.println(); } System.out.println("总个数为:"+sum); } }