#8183: JAVA 幫我看一下吧


qwpobird (qwpobird)


我有個疑問,,題目上的第一個input 2是什麼意思?
試問這個程式run幾次的意思嗎?
謝謝 
import java.util.Scanner;

public class J005 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int counter = sc.nextInt();
        while (counter != 0) {
            int[] abcd = new int[5];
            for (int i = 0; i <= 3; i++) {
                abcd[i] = sc.nextInt();
            }
            if (abcd[3] - abcd[2] == abcd[2] - abcd[1]) {
                abcd[4] = abcd[3] + (abcd[3] - abcd[2]);
            } else {
                abcd[4] = abcd[3] * (abcd[3] / abcd[2]);
            }


            for (int s = 0; s <= 4; s++) {
                System.out.print(abcd[s] + " ");
            }
            counter--;
        }
    }
}
#8186: Re:JAVA 幫我看一下吧


tomoyaken14 (歐練)


我有個疑問,,題目上的第一個input 2是什麼意思?
試問這個程式run幾次的意思嗎?
謝謝 
import java.util.Scanner;

public class J005 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int counter = sc.nextInt();
        while (counter != 0) {
            int[] abcd = new int[5];
            for (int i = 0; i <= 3; i++) {
                abcd[i] = sc.nextInt();
            }
            if (abcd[3] - abcd[2] == abcd[2] - abcd[1]) {
                abcd[4] = abcd[3] + (abcd[3] - abcd[2]);
            } else {
                abcd[4] = abcd[3] * (abcd[3] / abcd[2]);
            }


            for (int s = 0; s <= 4; s++) {
                System.out.print(abcd[s] + " ");
            }
            counter--;
        }
    }
}

輸入說明 :

第一行是數列的數目t(0 <= t <= 20)。