/*【程序11】
题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。 */
package test;
import java.util.ArrayList;
import java.util.List;
public class test {
public static void main(String args[])
{
List<Integer> list = new ArrayList<Integer>();
for(int i=123; i<432; i++)
{
int t = i;
int hund = 0;
int ten = 0;
int one = 0;
if(t/100>=1 && t/100<=4)
{
hund = t/100;
t = t - t/100*100;
if(t/10>=1 && t/10<=4)
{
ten = t/10;
t = t - t/10*10;
if(t>=1 && t<=4)
{
one = t;
if(one != ten && one !=hund && ten != hund)
list.add(i);
}
else continue;
}
else continue;
}
else continue;
}
for(int j = 0; j < list.size(); j++)
System.out.println(list.get(j));
}
}
转载于:https://blog.51cto.com/gomic/1414779