- 博客(125)
- 收藏
- 关注
原创 Introduction to Java Programming编程题9.31<刽子手游戏>
/*Enter a letter in word: ******** > tt is not in the word.Enter a letter in word: ******** > aEnter a letter in word: ******a* > lEnter a letter in word: ******al > nEnter a letter in word: ****
2015-08-29 00:48:02 783
原创 Introduction to Java Programming编程题9.19<写、读文件数据>
/*javac ReadAndWriteFile.javajava ReadAndWriteFile RandomInteger.txt1 1 1 2 2 2 4 4 4 56 6 6 7 8 8 9 10 10 1213 14 20 20 23 23 25 25 25 2829 29 30 32
2015-08-28 15:00:13 296
原创 Introduction to Java Programming编程题9.18<IO流处理>
/*File Score.txt number of the sum and average are:sum = 448.9Average = 44.9*//**Score.txt:-------------------------------------------------33.5 88 72 25 11.332.11 56 76 43 12*/import java.ut
2015-08-28 14:58:35 381
原创 Introduction to Java Programming编程题9.17<统计文件行、字符、单词数>
/*javac CountCharacters.javajava CountCharacters ToEndingLine.javaFile ToEndingLine.java has:8 lines.21 words.155 Characters.*//**ToEndingLine.java:--------------------------------------------
2015-08-28 14:56:23 351
原创 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 299
原创 Introduction to Java Programming编程题9.14<求字符串中整数的和>
/*qq:javacode qq$ javac Excercise9_14a.javaqq:javacode qq$ java Excercise9_14a 1 2 3 4 5The total is: 15*/public class Excercise9_14a { public static void main(String[] args) { int sum
2015-08-27 22:28:22 333
原创 Introduction to Java Programming编程题9.13<回文字符串(在命令行传字符串)>
/*qq:javacode qq$ javac CheckPalindrome.javaqq:javacode qq$ java CheckPalindrome myym"myym" is a Palindrome.qq:javacode qq$ java CheckPalindrome baidu"baidu" is not a Palindromeqq:javacode qq$ ja
2015-08-27 22:25:48 386
原创 Introduction to Java Programming编程题9.12<变位词>
/*Enter the first string: silentEnter the second string: listenAnagramEnter the first string: FlowerDanceEnter the second string: danceFlowerNot anagram */import java.util.Scanner;import java.
2015-08-27 22:22:44 330
原创 Introduction to Java Programming编程题9.11<对字符串中的字符排序(支持大小写混排)>
/*Enter a string: okwariaikorwEnter a string: ALMOSTloveraaAelLMoOrSTvEnter a string: BridgeToEternityBdeeEgiinorrttTy */import java.util.Scanner;public class StringSort { public static void
2015-08-27 17:06:48 390
原创 Introduction to Java Programming编程题9.10<十进制转二进制>
/*Enter a decimal number: 50B101Enter a decimal number: 450B101101 */import java.util.Scanner;public class DecimalToBinary { public static void main(String[] args) { Scanner input = n
2015-08-26 00:30:10 280
原创 Introduction to Java Programming编程题9.9<二进制转十六进制>
/*Enter a binary string: 00011000111118FEnter a binary string: 11000111118FEnter a binary string: 1010102A */import java.util.Scanner;public class BinaryToHex { public static void main(Strin
2015-08-25 16:41:02 321
原创 Introduction to Java Programming编程题9.8<二进制转十进制>
/*Enter a binary string: wx1234The string must be 0 or 1.Enter a binary string: 1234The string must be 0 or 1.Enter a binary string: 1000117 */import java.util.Scanner;public class BinaryToDeci
2015-08-25 16:27:54 246
原创 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 324
原创 Introduction to Java Programming编程题9.7<将字符串中的字符转换为数字>
/*Enter a string: 1-800-Flowers1-800-3569377Enter a string: 1800flowers18003569377 */import java.util.Scanner;public class CountLetter { public static void main(String[] args) { Scanner
2015-08-24 23:19:51 326
原创 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 464
转载 统计字符串中每个字母的个数
/*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 913
原创 Introduction to Java Programming编程题9.4<求某个字符的出现次数>
由于Java没有直接从Scanner类获取char字符的方法,所以只能用String接收字符串后通过charAt()将最后一个字符赋值给char类型。然后通过deleteChar(String str)行数将String最后一个字符删除。/*Enter the string: Prelude In Daydream.oCharacter 'o' in "Prelude In Daydream."
2015-08-24 20:31:38 266
原创 Introduction to Java Programming编程题9.3<检验密码>
/* Enter your passwords:1234 Invalid password. Enter your passwords:~!4456678999 Invalid password. Enter your passwords:The big bang 12 Invalid password. Enter your passwords:BambooDace12 Valid
2015-08-24 17:51:43 418
原创 Introduction to Java Programming编程题7.4<计算每个雇员每周工作小时数>
/*result:-----------------------------------------------sony:java sony$ java EmployeeHours < EmployeeHours.txtEmployee1: 41Employee2: 37Employee3: 34Employee4: 32Employee5: 31Employee6: 28Empl
2015-08-24 17:07:24 1780
原创 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 402
原创 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 428
原创 Introduction to Java Programming编程题8.13<返回二维数组中最大值及下标>
Enter the number of rows and columns of the array: 3 4Enter the array: 11 33.5 88.1 40 -2.2 -10.1 -201.11 2.22 3.3 4.4The location of the largest element is 88.1 at (0, 2)
2015-08-24 16:51:04 772
原创 Introduction to Java Programming编程题9.2<检查子串>
书上要求用户输入两个字符串,检测第一个字符串是否是第二个字符串的子串,我的程序刚好相反。按书上的要求的话只要调用isSubstring(str1, str2)时改为isSubstring(str2, str1)即可。
2015-08-24 16:36:25 547
原创 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 2095
原创 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 419
原创 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 339
原创 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 315
原创 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 411
原创 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 353
原创 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 281
原创 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 352
原创 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 351
原创 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 471
原创 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 254
原创 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 288
原创 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 648
原创 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 261
原创 求两个数的最大公因数
/*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 499
原创 彩票游戏
Enter your lottery pick (three digits): 124The lottery number is : 626Match one digit: you win $1,000
2015-08-19 17:43:08 365
原创 输入年、月、日,计算其为星期几
/*Enter year:(e.g., 2012): 2015Enter month: 1-12: 1Enter the day of the month: 1-31: 25Day of the week is Sunday.Enter year:(e.g., 2012): 2012Enter month: 1-12: 5Enter the day of the month: 1-31:
2015-08-19 17:32:32 402
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人