標籤:程式設計語言 markdown default OLE 上傳 variables 比較 另一個 數學
20172324《Java程式設計》第六周學習總結教材學習內容總結
for(int ch=0;ch<line.length();ch++) { current = line.charAt(ch);//定義current是輸入的字串從索引0開始的字元 if(current>=‘A‘&¤t<=‘Z‘)//這裡和Unicode有關,如果這個大寫字母在A`Z之間 upper[current-‘A‘]++;//那麼current-‘A‘就代表索引處那個特定的字元,索引處的值加1(最開始是0,因為沒有出現過) else if(current>=‘a‘&¤t<=‘z‘)//同上嘛,就是小寫而已。 lower[current-‘a‘]++; else other++; }
代碼調試中的問題和解決過程
String another = "y";//建立一個字串命令它表示為y int[] list = new int[50];//可以放50個數的數組 //建立一個可以連續輸入數位迴圈 while(another.equalsIgnoreCase("y"))//哦~這裡的another要和下面輸入的another做比較 { Scanner scan = new Scanner(System.in); System.out.print("是否繼續輸入(y/n): "); another = scan.nextLine();//就是這裡的 if (another.equalsIgnoreCase("y") )//another輸入為y就可以輸入資料,所以不需要多的字串。 { System.out.print("Enter your number: "); number = scan.nextInt(); list[i] = number; i++; } }
## 代碼託管
(statistics.sh指令碼的運行結果)
上周考試錯題總結
- The idea that program instructions execute in order (linearly) unless otherwise specified through a conditional statement is known as
A . boolean execution
B . conditional statements
C . try and catch
D . sequentiality
==E . flow of control==
"控制流程" 描述指令執行的順序。它預設為線性 (或連續), 但通過使用諸如條件和迴圈等控制語句來改變。
- Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?
A . if (x > 0) x++;
else x--;
==B . if (x > 0) x++;
else if (x < 0) x--;==
C . if (x > 0) x++;
if (x < 0) x--;
else x = 0;
D . if (x == 0) x = 0;
else x++;
x--;
E . x++;
x--;
如果 x 為正數, 則在 x 為負 x 的情況下執行 x++, 否則, 不會發生任何情況, 或者 x 不受影響。在 A、C、D 和 E 中, 邏輯不正確。在 A, x-是做如果 x 是不積極的, 因此, 如果 x 是 0, x 成為-1, 這是錯誤的答案。在 C 中, 如果 x 為正數, 則執行 x++。在任一情況下, 將執行下一語句, 如果 x 不是負值, 則執行 else 子句將 x 設定為0。因此, 如果 x 是正數, 則在這組代碼之後變為0。如果 x 不是 0, 則在 D、x++ 和 x 中都執行。在 E 中, 此代碼不嘗試確定 x 是正數還是負數, 它只添加一個, 然後從 x 中減去 1, 使 x 相同。
- Assume that count is 0, total is 20 and max is 1. The following statement will do which of the following? if (count != 0 && total / count > max) max = total / count;
==A . The condition short circuits and the assignment statement is not executed==
B . The condition short circuits and the assignment statement is executed without problem
C . The condition does not short circuit causing a division by zero error
D . The condition short circuits so that there is no division by zero error when evaluating the condition, but the assignment statement causes a division by zero error
E . The condition will not compile because it uses improper syntax
因為計數是 0, (計數! = 0) 是假的。因為 & & 條件的左手邊是假的, 所以條件是短路的, 所以右手邊是不計算的。因此, 避免了潛在的除法錯誤。由於條件為 false, 語句最大 = 總計/計數未執行, 再次避免潛在除法為零錯誤。
- Which of the following are true statements about check boxes?
A . they may be checked or unchecked
B . radio buttons are a special kind of check boxes
C . they are Java components
D . you can control whether or not they will be visible
==E . all of the above==
有關複選框的四個語句中的每一個都是 true。
- When comparing any primitive type of variable, == should always be used to test to see if two values are equal.
A . true
==B . false==
這對 int、短、位元組、長、char 和布爾值都是正確的, 但不能是雙變數或浮點函數。
- You might choose to use a switch statement instead of nested if-else statements if
A . the variable being tested might equal one of several hundred int values
==B . the variable being tested might equal one of only a few int values==
C . there are two or more int variables being tested, each of which could be one of several hundred values
D . there are two or more int variables being tested, each of which could be one of only a few values
E . none of the above, you would never choose to use a switch statement in place of nested if-else statements under any circumstance
只有在測試單個變數並且它是整數類型 (在 Java 中為 int 或 char) 時, 才可以使用 switch 語句。
- If a switch statement is written that contains no break statements whatsoever,
A . this is a syntax error and an appropriate error message will be generated
B . each of the case clauses will be executed every time the switch statement is encountered
C . this is equivalent to having the switch statement always take the default clause, if one is present
D . this is not an error, but nothing within the switch statement ever will be executed
==E . none of the above==
雖然寫這樣一個開關聲明是不尋常的, 它是完全合法的。切換語句執行的常規規則應用在計算切換運算式後執行的匹配 case 子句。隨後, 所有後續子句都按順序執行, 因為沒有中斷語句來終止交換器/案例執行。
- The statement if (x < 0) y = x; else y = 0; can be rewritten using a conditional operator as
==A . y = (x < 0) ? x : 0;==
B . x = (x < 0) ? y : 0;
C . (x < 0) ? y = x : y = 0;
D . y = (x < 0);
==E . y = if (x < 0) x : 0;==
看書看書看書看書看書看書
- How many times will the following loop iterate?
int x = 10;
do {
System.out.println(x);
x--;
} while (x > 0);
A . 0 times
B . 1 times
C . 9 times
D . 10 times
==E . 11 times==
沒話說….do迴圈一定會執行一次的,好好學數學,好好數。
- Given that s is a String, what does the following loop do?
for (int j = s.length( ); j > 0; j--)
System.out.print(s.charAt(j-1));
==A . it prints s out backwards==
B . it prints s out forwards
C . it prints s out backwards after skipping the last character
D . it prints s out backwards but does not print the 0th character
E . it yields a run-time error because there is no character at s.charAt(j-1) for j = 0
變數 j 從字串的長度向下計數為 1, 每次列印出位置 j-1 的字元。長度為1的字元是第一個列印字元, 這是字串的最後一個字元。它繼續, 直到它達到 j = 1, 並列印出的字元在位置 j-1, 或第0字元, 所以它列印整個字串向後。
- In Java, it is possible to create an infinite loop out of while and do loops, but not for-loops.
A .true
B .false
誠然, 雖然while和do迴圈可以是無限迴圈, 但for 迴圈可以是無限迴圈。在許多其他程式設計語言中, 這不是真的, for 迴圈有一個設定的開始和結束點, 但是 Java for 迴圈比大多數其他語言的 for 迴圈要靈活得多
結對及互評點評模板(why點評我!)
- 正確使用Markdown文法(加1分)
- 模板中的要素齊全(加1分)
- 教材學習中的問題和解決過程, 加4分
- 代碼調試中的問題和解決過程, 加4分
- 本周有效代碼超過300分行,加2分
- 其他加分,加2分
- 排版精美的加一分
- 進度條中記錄學習時間與改進情況的加1分
本周結對學習情況
其他(感悟、思考等,可選)
我學得要死不活的時候,王志偉說很簡單。我感覺好悲傷,希望能夠打他一頓解心頭之狠。這個星期的感悟結束。
學習進度條
|
程式碼數(新增積) |
部落格量(新增積) |
學習時間(新增積) |
重要成長 |
| 目標 |
5000行 |
30篇 |
400小時 |
|
| 第一周 |
200/200 |
2/2 |
20/20 |
|
| 第二周 |
329/500 |
2/4 |
18/38 |
|
| 第三周 |
619/1000 |
3/7 |
22/60 |
|
| 第四周 |
817/1734 |
4/7 |
38/60 |
|
| 第五周 |
674/2408 |
5/7 |
38/60 |
|
| 第劉周 |
1136/2870 |
6/7 |
50/60 |
|
參考資料
2017-2018-2學期 20172324《Java程式設計》第六周學習總結