java 第二週考試錯誤彙總
阿新 • • 發佈:2020-11-23
int s = 0;
for (int i = 0; i < MyArray.length; i++)
if (i % 2 == 0)
s = s+ MyArray[i];
System.out.println(s);
執行後s的值是()B
int i = 0,j = -1;
switch(i) {
case 0:j=1;
case 1:j=2;
case 2:j=2;
default:j=5;
}
System.out.println("j=" + j)
編譯之後,正確的是()
class testException {
int sum = 0;
public static void main(String[] args){
int n[] = {0,1,2,3,4};
for (int i = 1; i <=4; i++) {
sum = sum + n[i];
}
}
System.out.println("sum = " + sum);
}
輸出結果是()
temp = score[0];
for (int index = 1; index < 5;index++){
if (score[index] < temp)
{
temp = score[index];
}
}
System.out.println(“請輸入一個正整數:”);
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
int result = 1;
for(int i = 1; i <= number; i++) {
______ result = result * i______
-
i=_______,a[i] =_________;(1,2)arr[i++] += b == arr[i++] = 具體值 + b;