2013年8月26日
摘要: 题目:输入两个正整数m和n,求其最大公约数和最小公倍数。 1 import java.util.Scanner; 2 3 4 public class Algorithm_Game_06 { 5 public static void main(String[] args) { 6 Scanner s = new Scanner(System.in); 7 int m = s.nextInt(); 8 int n = s.nextInt(); 9 System.out.println("最大公约数:"+f(m, n));... 阅读全文
posted @ 2013-08-26 20:00 elleniou 阅读(8544) 评论(0) 推荐(0) 编辑
摘要: 利用条件运算符的嵌套来完成此题:学习成绩> =90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。 1 import java.util.Scanner; 2 3 4 public class Algorithm_Game_05 { 5 6 public static void main(String[] args) { 7 8 Scanner s = new Scanner(System.in); 9 int n = s.nextInt();10 String str = "";11 ... 阅读全文
posted @ 2013-08-26 19:32 elleniou 阅读(1644) 评论(0) 推荐(0) 编辑
摘要: 将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。 1 import java.util.Scanner; 2 3 public class Algorithm_Game_04 { 4 public static void main(String[] args) { 5 6 Scanner scanner = new Scanner(System.in); 7 8 int n = scanner.nextInt(); 9 String str = n + " = 1*";10 int... 阅读全文
posted @ 2013-08-26 19:19 elleniou 阅读(594) 评论(0) 推荐(0) 编辑
摘要: 题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",因为153=1的三次方+5的三次方+3的三次方。1 public class Algorithm_Game_03 {2 public static void main(String[] args) {3 for(int i = 100 ; i ");6 }7 }8 }9 } 阅读全文
posted @ 2013-08-26 18:37 elleniou 阅读(1404) 评论(0) 推荐(0) 编辑
摘要: 题目:判断101-200之间有多少个素数,并输出所有素数。 1 public class Algorithm_Game_02 { 2 public static void main(String[] args) { 3 for(int i = 101 ; i ");12 } 13 }14 } 阅读全文
posted @ 2013-08-26 17:12 elleniou 阅读(571) 评论(3) 推荐(0) 编辑
摘要: 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第四个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?1.程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21.... 1 public class Algorithm_Game_01 { 2 3 public static void main(String[] args) { 4 int month = 20; 5 for(int i = 1 ; i "); 7 } 8 } 9 public static i... 阅读全文
posted @ 2013-08-26 16:58 elleniou 阅读(1174) 评论(0) 推荐(0) 编辑