大三学长带我学习JAVA.作业8。。1 有1、2、3、4这几个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
2013年1月16日星期三
1 有1、2、3、4这几个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
public class Zhouhai {
public static void main(String[] args) {
int n = 0;
for(int a = 1; a <= 4; a ++)
for(int b = 1; b <= 4; b ++)
for(int c = 1; c <= 4; c ++)
if(a != b && a != c && b != c ) {
++n;
System.out.print(a+""+b+""+c+" ");
if(n % 4 == 0)
System.out.print("\n");
}
System.out.println("共有"+n+"种");
}
}