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 秒完成。

想多做几道同类题目?立即开始练习这个课题,边做边批改。

立即练习