AP (Advanced Placement) · AP Computer Science A

Algorithms with Selection and Repetition:練習問題

その場で採点される選択問題 5 問と、解説つきの記述問題 1 問。すべて「Algorithms with Selection and Repetition」からの出題です。

6 問10 無料・登録不要
問 1
1

How many times will the following loop execute?
for (int i = 0; i < 10; i += 3) {
  System.out.println(i);
}

問 2
1

Given that a, b, and c are boolean variables, which of the following expressions will always evaluate to the same value as (a && b) || (a && c)?

問 3
1

A student is writing a program to find the largest power of 2 that is less than or equal to a positive integer n. Which of the following code segments correctly computes this value and stores it in ans?

問 4
1

Which of the following logical expressions is equivalent to the expression !(a || b) according to De Morgan's Laws?

問 5
1

What is the output of the following code segment?
int count = 0;
for (int i = 1; i <= 3; i++) {
  for (int j = 1; j < 3; j++) {
    count++;
  }
}
System.out.println(count);

問 6
5

A program is designed to analyze a sequence of integers entered by a user until the user enters -1.
Part a: Using a while loop, write a logic flow that calculates the sum of all positive even integers entered.
Part b: Integrate an if-else structure to track the maximum value among the entered positive integers.
Part c: If the user enters the sequence: 4, 7, 2, 10, -1, determine the final values of the sum and the maximum. Show the state of these variables after each iteration.

まず自分で答えを書いてから、解説と照らし合わせましょう。

※ thinkaのコンテンツはAIにより生成されているため、内容が正確でない場合があります。補助教材としてご使用いただき、公式の教材と合わせてご確認ください。

模範解答は見ました。次はあなたの答案を採点します。

このページは良い答案の形を示せますが、あなたの答案に何が足りないかは教えられません。thinka は実際の採点基準に沿って記述答案を約 15 秒で採点します。

同じような問題をもっと解きたい?このトピックの新しい問題を、解きながら採点。

練習を始める