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 and write the dequeued character to the screen
else
enqueue the character into the queue
}What is written to the screen for the input "H*owAre***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: "HowAreYouT". Hàng đợi trả ra theo đúng thứ tự nhận vào, nên mỗi dấu sao in chữ cái vào sớm nhất mà chưa in. Dãy nhập có mười dấu sao nên màn hình nhận mười chữ, lấy từ dãy chữ cái vào lần lượt là H, o, w, A, r, e, Y, o, u, T, o, D, a, y; mười chữ đầu của dãy đó cho HowAreYouT, phần o, D, a, y còn nằm lại trong hàng đợi. "HowAreYou" sai vì nó chỉ có chín chữ, tức bỏ sót một dấu sao trong cụm bốn sao trước chữ D. "owAreYouTo" sai vì nó bỏ chữ H, nhưng H vào đầu tiên nên dấu sao ngay sau nó phải in ra chính H. "wAreYouTo" sai vì nó vừa thiếu một chữ so với số dấu sao, vừa bỏ cả H và o là hai chữ vào sớm nhất.
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