摘要:
1 //使用Eratoshene滤网来生成2~1000之间的素数。 2 import acm.program.*; 3 public class Eratosthene extends ConsoleProgram { 4 public void run(){ 5 prime = new int[999]; 6 for(int i = 0; i < 999; i++) { 7 prime[i] = i + 2; 8 } 9 int j = 0;10 int num =0;11 ... 阅读全文
摘要:
//读入7名裁判所打的分数,计算去掉最高分和最低分之后剩余的5个分数的平均值。import acm.program.*;public class score extends ConsoleProgram{ public void run(){ score = new int[NUM]; int sum = 0; double average = 0; for (int i = 0; i < NUM; i++) { score[i] = readInt("Input the score " + i + " : "... 阅读全文
摘要:
1 /* 2 * File: PigLatin.java 3 * -------------- 4 * This file takes a line of text and converts each word into Pig Latin. 5 * The rules for forming Pig Latin words are as follows: 6 * - If the word begins with a vowel, add "way" to the end of the word. 7 * - If the word begins with a conso 阅读全文