Java
Okwarry
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Introduction to Java Programming编程题5.26<回文素数>
/*2 3 5 7 11 101 131 151 181 191313 353 373 383 727 757 787 797 919 92910301 10501 10601 11311 11411 12421 12721 12821 13331 1383113931 14341 14741 15451 15551原创 2015-08-19 18:05:58 · 360 阅读 · 0 评论 -
Introduction to Java Programming编程题5.28<梅森素数>
/*p 2p - 12 33 75 317 12713 819117 13107119 52428731 2147483647*/public class MeiSenPrime { public static void main(String[] args) { int p2; System.out.println("p\t"原创 2015-08-19 18:09:57 · 416 阅读 · 0 评论 -
Introduction to Java Programming编程题6.3<计算数字的出现次数>
/*Enter the integers between 1 and 100: 2 5 6 5 4 3 23 43 2 02 occurs 2 times.3 occurs 1 times.4 occurs 1 times.5 occurs 2 times.6 occurs 1 times.23 occurs 1 times.43 occurs 1 times. */import原创 2015-08-19 18:19:57 · 510 阅读 · 0 评论 -
Introduction to Java Programming编程题6.6<判别素数高效版>
判断n是否为素数,可先求出n的平方根(squreRoot),然后n除以2 <= squreRoot之间的数字,不能整除即为素数。/*2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137原创 2015-08-19 21:41:17 · 392 阅读 · 0 评论 -
Introduction to Java Programming编程题6.7<统计0~9随机数出现的次数>
/*The random digits:--------------------------------2 5 9 9 1 9 2 7 0 19 2 4 2 7 5 4 5 6 12 4 7 8 1 7 6 8 2 95 5 9 9 2 5 2 2 5 66 9 2 2 1 9 6 2 1 32原创 2015-08-19 22:26:52 · 401 阅读 · 0 评论 -
introduction to Java Programming 编程题5.3<回文整数>
输入一个整数,判断其是否为回文整数。原创 2015-08-16 15:22:44 · 406 阅读 · 0 评论 -
introduction to Java Programming 编程题5.4<反向显示一个整数>
反向显示一个整数原创 2015-08-16 15:20:55 · 704 阅读 · 0 评论 -
打印2的n次方数字三角形
/*22 42 4 82 4 8 162 4 8 16 322 4 8 16 32 64*/public class Test { public static void main(String[] args) { int i = 1; while (i <= 6) { method1(i, 2); i++; } } public原创 2015-08-19 16:11:38 · 457 阅读 · 0 评论 -
Introduction to Java Programming编程题5.13<数列求和>
/*Enter a digit number: 3i m(i)1 0.52 1.16666666666666653 1.9166666666666665*/import java.util.Scanner;public class SumOrderedSeries { public static void main(String[] args) { Scan原创 2015-08-19 16:42:13 · 345 阅读 · 0 评论 -
打印答题时间、正确题目数
/*What's 25-32 ? 556What's 34-13 ? 90What's 69-91 ? -22What's 66-86 ? 20What's 8-51 ? -43Correct count is: 2Test time is: 0 hour 8 minute 24 seconds25-32=556 wrong.34-13=90 wrong.69-91=-原创 2015-08-19 16:51:49 · 389 阅读 · 0 评论 -
Introduction to Java Programming编程题6.1<为学生分数转换为ABCDF>
/*Enter the number of the students: 4Enter 4 scores: 40 55 70 58Student 1 score is 40 and grade is: CStudent 2 score is 55 and grade is: BStudent 3 score is 70 and grade is: AStudent 4 score is 5原创 2015-08-19 16:55:17 · 399 阅读 · 0 评论 -
Introduction to Java Programming编程题3.22<判断点是否在矩形内>
/*Enter a point with two coordinates: 2 7Point (2.0, 7.0) is not in the rectangle.Enter a point with two coordinates: 2 2Point (2.0, 2.0) is in the rectangle.*/import java.util.Scanner;public clas原创 2015-08-19 17:22:00 · 503 阅读 · 0 评论 -
Introduction to Java Programming编程题3.22<判断点是否在圆内>
/*Enter a point with two coordinates: 4 5Point (4.0, 5.0) is in the circle.Enter a point with two coordinates: 9 9Point (9.0, 9.0) is not in the circle.*/import java.util.Scanner;public class Poin原创 2015-08-19 17:25:42 · 379 阅读 · 0 评论 -
彩票游戏
Enter your lottery pick (three digits): 124The lottery number is : 626Match one digit: you win $1,000原创 2015-08-19 17:43:08 · 419 阅读 · 0 评论 -
求两个数的最大公因数
/*Enter two integer: 33 100They haven't any common divizor.Enter two integer: 100 330This greatest common divisor for 100 and 330 is 10Enter two integer: 222 123This greatest common divisor for 2原创 2015-08-19 17:52:04 · 595 阅读 · 0 评论 -
Introduction to Java Programming编程题5.14<计算数列>
运行结果与书上不符以,疑为书籍排版错误。书上原题:m(i)=4(1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 +……+ 1/(2i-1) - 1/(2i+1))若i = 10,展开应为:m(i)=4(1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 - 1/15 + 1/17 - 1/19 + 1/21)i m(i)10 3.232原创 2015-08-19 17:59:52 · 320 阅读 · 0 评论 -
Introduction to Java Programming编程题5.17<01矩阵>
public class MatrixZeroOne { public static void main(String[] args) { int randomNumber; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { randomNumber = (int)(Math.ran原创 2015-08-19 18:01:59 · 739 阅读 · 0 评论 -
Introduction to Java Programming编程题5.27<反素数>
/*13 17 31 37 71 73 79 97 107 113149 157 167 179 199 311 337 347 359 389701 709 733 739 743 751 761 769 907 937941 953 967 971 983 991 1009 1021 1031 10331061 1069 1091 1原创 2015-08-19 18:07:30 · 353 阅读 · 0 评论 -
Introduction to Java Programming编程题5.29<掷骰子游戏>
/*You rolled 2 + 1 = 3You loseYou rolled 1 + 4 = 5Point is 5You rolled 5 + 1 = 6You rolled 5 + 1 = 6You rolled 1 + 5 = 6You rolled 6 + 3 = 9You rolled 1 + 4 = 5You winYou rolled 5 + 2 = 7You w原创 2015-08-19 18:08:43 · 552 阅读 · 0 评论 -
Introduction to Java Programming编程题5.30<双素数>
/*(3, 5)(5, 7)(11, 13)(17, 19)(29, 31)(41, 43)(59, 61)(71, 73)(101, 103)(107, 109)(137, 139)(149, 151)(179, 181)(191, 193)(197, 199)(227, 229)(239, 241)(269, 271)(281, 283)(311, 313原创 2015-08-19 18:10:53 · 439 阅读 · 0 评论 -
Introduction to Java Programming编程题5.33<显示当前日期和时间>
/*Current data and time is August 18, 2015 6:8:23.*/public class CurrentTime { public static void main(String[] args) { showTime(); } public static void showTime() { final原创 2015-08-19 18:18:24 · 456 阅读 · 0 评论 -
求一个整数的所有位相加之和
/*Enter a digit number: 234digit sum: 9brown:javacode brown$ java SumDigitsEnter a digit number: 1551digit sum: 12*/import java.util.Scanner;public class SumDigits { public static void main(Str原创 2015-08-19 16:43:27 · 719 阅读 · 0 评论 -
翻转整数
import java.util.Scanner;public class ReverseDigit { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a digit number: "); int numbe原创 2015-08-19 17:10:26 · 362 阅读 · 0 评论 -
Introduction to Java Programming编程题5.32<赢取双骰子游戏的次数>
/*You rolled 5 + 5 = 10Point is 10You rolled 6 + 2 = 8Point is 8You rolled 5 + 2 = 7You lose1********************You rolled 3 + 3 = 6Point is 6You rolled 6 + 4 = 10You win2*****************原创 2015-08-19 18:13:51 · 341 阅读 · 0 评论 -
Introduction to Java Programming编程题11.1<The triangle class>
运行结果:Triangle: side1 = 1.0 side2 = 1.0 side3 = 1.0color: greenfilled: falseTriangle: side1 = 1.0 side2 = 1.5 side3 = 1.0color: yellowfilled: trueGeometricObject.javapackage Uber;public class Geom原创 2015-09-26 12:57:26 · 976 阅读 · 0 评论 -
Introduction to Java Programming编程题6.20<经典八皇后难题>
解题思路: 1.先打印整张棋盘的边界线,‘|’与‘|’之间填充空格; 2. except数组存放棋盘上已经放置了Queen的下标,例如第一行Q的下标为1,则第二行Q的下标index !=1 && index != 1+2 && index != 1-2, && index != (0~16之间的偶数),以此类推。/*|Q| | | | | | | || | | | | | |Q| || |原创 2015-08-20 20:06:13 · 498 阅读 · 0 评论 -
Introduction to Java Programming编程题12.1<NumberFormatException>
运行结果:br:javacode br$ javac NumberFormatException.javabr:javacode br$ java NumberFormatException 45 34Please use java NumberFormatException operand1 operator operand2java NumberFormatException 45x +原创 2015-09-28 17:29:05 · 739 阅读 · 0 评论 -
Introduction to Java Programming编程题12.2<InputMismatchException>
运行结果:Enter two digital number: tr ru hdInvalid digital number.Enter two digital number: 45 qaInvalid digital number.Enter two digital number: 12 1112 + 11 = 23InputException.javaimport java.util.I原创 2015-09-28 19:14:32 · 663 阅读 · 0 评论 -
Introduction to Java Programming编程题12.3<ArrayIndexOutBoundsException>
运行结果:Enter the array's index less than 100: -5 q 111 9Out of bounds.Enter the array's index less than 100: qqIndex must be digital.Enter the array's index less than 100: 5Index 5: 144ArrayIndexOut原创 2015-09-28 19:58:09 · 752 阅读 · 0 评论 -
Introduction to Java Programming编程题12.11<Remove text>
运行结果:brown:javacode br$ javac Where.javabrown:javacode br$ java Where miyu.txt xiyu.txt [(粉丝群)]-bash: syntax error near unexpected token `(' brown:javacode br$ java Where miyu.txt xiyu.txt 粉丝群brow原创 2015-09-29 13:32:44 · 642 阅读 · 0 评论 -
Introduction to Java Programming编程题8.36<Latin square>
运行结果:Enter number n: 4Enter 4 rows of letters separated by spaces:A B C DB A D CC D B AD C A BThe input array is a Latin square.Enter number n: 3Enter 3 rows of letters separated by spaces:A F原创 2015-09-24 11:19:21 · 650 阅读 · 0 评论 -
Introduction to Java Programming编程题8.37<Guess the capitals>
运行结果:What is the capital of Alabama? MontogomeryThe correct answer should be Montgomery.What is the capital of Alaska? JuneauYour answer is correct.What is the capital of Arizona? PhoEnixThe corre原创 2015-09-24 12:08:33 · 834 阅读 · 0 评论 -
Introduction to Java Programming编程题9.15<求字符串中大写字母的个数>
/*java CountUpperCase RollingInTheDeepThe uppercase total is: 4java CountUpperCase Rolling In The Deep Adele Steven Sharp Nelson Jon Schmidt.The uppercase total is: 10 */public class CountUpperCas原创 2015-08-27 22:51:15 · 376 阅读 · 0 评论 -
Introduction to Java Programming编程题9.1<检查SSN>
Enter your SSN: 123-45-666666 Invalid SSN. Enter your SSN: okl-33-4444 Invalid SSN. Enter your SSN: 123-45-6789 Valid SSN原创 2015-08-24 16:28:32 · 2650 阅读 · 0 评论 -
Introduction to Java Programming编程题9.2<检查子串>
书上要求用户输入两个字符串,检测第一个字符串是否是第二个字符串的子串,我的程序刚好相反。按书上的要求的话只要调用isSubstring(str1, str2)时改为isSubstring(str2, str1)即可。原创 2015-08-24 16:36:25 · 617 阅读 · 0 评论 -
Introduction to Java Programming编程题7.11<硬币游戏:显示正反面>
Enter a number beteewn 0 and 511: 7H H HH H HT T T原创 2015-08-24 16:54:26 · 530 阅读 · 0 评论 -
Introduction to Java Programming编程题7.6<两个矩阵相乘>
Enter matrix1: 1 2 3 4 5 6 7 8 9Enter matrix2: 0 2 4 1 4.5 2.2 1.1 4.3 5.2The mattrices are multiplied as follows:5.3 23.9 24.011.6 56.3 58.217.9 88.7 92.4原创 2015-08-24 17:04:44 · 497 阅读 · 0 评论 -
统计字符串中每个字母的个数
/*Enter a string: almost lover 123a appers 1 time.e appers 1 time.l appers 2 times.m appers 1 time.o appers 2 times.r appers 1 time.s appers 1 time.t appers 1 time.v appers 1 time. */import转载 2015-08-24 22:23:20 · 1001 阅读 · 0 评论 -
Introduction to Java Programming编程题9.6<统计字符串中字母的个数>
/*Enter a string: Joe going out, 78011 characters. */import java.util.Scanner;public class CountLetter { public static void main(String[] args) { Scanner input = new Scanner(System.in);原创 2015-08-24 22:33:23 · 549 阅读 · 0 评论 -
Introduction to Java Programming编程题9.5<统计字符串中数字的个数>
/*Enter a string: jdk.8.0.40 and the big bang 33594210 appers 2 times.1 appers 1 time.2 appers 1 time.3 appers 2 times.4 appers 2 times.5 appers 1 time.8 appers 1 time.9 appers 1 time. */imp原创 2015-08-24 23:55:54 · 389 阅读 · 0 评论
分享