540 câu trắc nghiệm tổng hợp Toán rời rạc có đáp án - Phần 9

Cho thuật toán: Procedure Test(x,i,j: Integer); Var m:integer; Begin m:=trunc(i+j)/2; If x= a[i] then vt:=m Else If (x < a[m] ) and (i a[m] ) and (j>m) then Test(x,m+1,j) Else vt:=0; End; Vớ

24/30

Cho thuật toán:

Procedure Test(x,i,j: Integer);

Var m:integer;

Begin

m:=trunc(i+j)/2;

If x= a[i] then vt:=m

Else If (x < a[m] ) and (i

Else If (x > a[m] ) and (j>m) then Test(x,m+1,j)

Else vt:=0;

End;

Với A = {5, 2, 9 ,8, 6, 4, 7,1}. Kết quả nào đúng trong số những kết quả dưới đây:

>

Test(3,1,8), vt = 0;

Test(4,1,8), vt = 5;

Test(6,1,8), vt = 0;

Test(7,1,8), vt = 8;

Giải thích

Chọn đáp án A