101地特三等資料處理 加三碼字串 - 考試
By Christine
at 2013-07-27T11:42
at 2013-07-27T11:42
Table of Contents
四、撰寫一個函數(function)接受一個字串,將該字串轉換成加三碼字串。加三碼的
用如下:A→D, B→E, …, W→Z, X→A, Y→B, Z→C。因此一字串CAMPUSSTYLE
的加三碼字串為FDPSXVVWBOH。
補習班解答如下
01 public String AddThreeCodes(String inputstring)
02 { int i, j;
03 char c;
04 String outputstring = " ";
05 for (i = 0; i < inputstring.length(); i++ )
06 { c = inputstring.charAt( i );
07 j = (int) c;
08 j = j + 3;
09 c = (char) j;
10 outputstring = outputstring + String.valueOf(c); }
11 System.out.println(outputstring);
12 Return outputstring}
不才有借書來看,但有些不懂
故想請問第 07 j = (int) c;
09 c = (char) j;
不才推測它是否可以這樣解釋?
變數j等於字元c所對應的整數值
字元c等於整數j所對應的字元值
是否任意的變數型態轉換都這樣寫就可?
另外,11 System.out.println(outputstring);
12 Return outputstring}
兩行是否只須寫其一就可?
再麻煩各位替不才做個較詳細指導了,謝謝!
--
Tags:
考試
All Comments
By Sandy
at 2013-07-31T14:04
at 2013-07-31T14:04
By Audriana
at 2013-07-31T23:38
at 2013-07-31T23:38
By Yuri
at 2013-08-05T06:11
at 2013-08-05T06:11
Related Posts
短期內不會再參加任何研訊院舉辦的考試
By Charlotte
at 2013-07-27T11:36
at 2013-07-27T11:36
高雄達特轉讓 全科班三萬六
By Ursula
at 2013-07-27T11:20
at 2013-07-27T11:20
請益台北志光的英文師資
By Enid
at 2013-07-27T11:19
at 2013-07-27T11:19
請問國營化學的錄取分數
By Linda
at 2013-07-27T11:14
at 2013-07-27T11:14
短期內不會再參加任何研訊院舉辦的考試
By Sarah
at 2013-07-27T10:28
at 2013-07-27T10:28