Consider the following pseudocode: declare a queue of characters
4 phương ánCó giải thích
while(there are more characters in the word to read){read a character if a character is '*' then dequeue the queue
else
enqueue the character into the queue
}
while(the queue is not empty)dequeue and write the dequeued character to the screen What is written to the screen for the input "HowAre***You**To**Day " ?
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "ouToDay". Hàng đợi vào trước ra trước, nên mỗi dấu sao loại bỏ ký tự cũ nhất còn trong hàng, và vòng cuối in ra theo đúng thứ tự nạp vào. Chạy tay theo đúng thứ tự ký tự của từ: nạp H, o, w, A, r, e; ba dấu sao bỏ H, o, w, còn A, r, e; nạp Y, o, u; hai dấu sao bỏ A, r, còn e, Y, o, u; nạp T, o; hai dấu sao bỏ e và Y, còn o, u, T, o; nạp D, a, y. Hàng còn o, u, T, o, D, a, y và in ra đúng dãy đó. "uToDay" thiếu chữ o đứng đầu, tức tính thừa một lần loại bỏ so với bảy dấu sao có trong từ. "ouToDa" thiếu y ở cuối, dù y được nạp sau dấu sao cuối cùng nên không ai lấy nó ra. "yaDoTu" là dãy đảo ngược, đó là cách lấy ra của ngăn xếp chứ không phải của hàng đợi.
Cùng phần 2
Select the statement that is most correct.
Which of the following applications may not use a stack?Có lời giảiCâu hỏiConsider the following pseudocode:
declare a stack of characters
while(there are more characters in the word to read)
{read a character
if a character is '*' then
pop the stack
else
push the character into the stack
}
while(the stack is not empty)
pop and write the poped character to the screen
What is written to the screen for the input "Good**Morn**in***g" ?Có lời giảiCâu hỏiConsider the following pseudocode:
declare a stack of characters
while(there are more characters in the word to read)
{read a character
if a character is '*' then
pop and write the poped character to the screen
else
push the character into the stack
}
What is written to the screen for the input "Good**Morn**i***ng" ?Có lời giảiCâu hỏiCả 51 câu của chủ đề51 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây