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 วินาที

อยากฝึกโจทย์แบบนี้เพิ่มไหม เริ่มฝึกหัวข้อนี้ได้เลย ตรวจให้ทันทีทุกข้อ

เริ่มฝึกเลย