# 8/21 K速記 * 手寫題 請求出下列程式碼執行過後a的數值 ```java= int a = 1, b = 2; a = (b * a--) * ++a; ``` <K想法> ( 2 * 1 ) * 1 = 2 ```java= int a = 1, b = 2; a = (a * ++b) / ++a; ``` <K想法> ( 1 * 3 ) / 2 = 1 ```java= int a = 4; a += a * a; ``` <K想法> a = a + (a * a) = 4 + ( 4 * 4 ) = 20 ```java= int a = 1, b = 2; a *= a++ + ++b; ``` <K想法> a = a * ( a++ + ++b ) = 1 * (1 + 3) = 4 > 手寫題有幾個容易忽略的地方: > 1、開頭部分 package 及import > 2、class 後面的名稱 開頭為大寫 > 3、main的 參數 String[] args要熟記 > 4、建議在函式的結尾 加上註記 如main的最後加上註解 >}//end of main >}//end of class > 5、Scanner sc = new Scanner(System.in); //需要大寫的地方要正確 > 6、注意break;的使用,尤其是在switch內 若還有for迴圈, > 可用boolen變數紀錄,作為外圈跳出的flag。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up