摘要: 题目:用1、2、3、4、5这五个数字,打印出所有不同的数字排列,如:51234、41235、31254等,要求:"4"不能在第三位,"3"与"5"不能相连,一个排列中数字不能重复。题目分析:该五个数字组合实际上是一个数,这个数中最大为54321,最小为12345,因此可以用循环遍历出来。编程实现:public class RankNumber{ private static String [] number = new String [] {"1","2","3"," 阅读全文
posted @ 2012-01-25 17:01 qin520 阅读(520) 评论(0) 推荐(0) 编辑
摘要: 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。1.程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。编程实现:import java.util.*;public class DaffodilTest{ public static void main(String args[]){ int hundred = 0; int ten = 0; int bit = 0; for(int 阅读全文
posted @ 2012-01-25 15:58 qin520 阅读(350) 评论(0) 推荐(0) 编辑