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 "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: "HowAre". Ở biến thể này mỗi dấu sao lấy ký tự ở đầu hàng đợi và in ngay, còn các ký tự khác chỉ được nạp vào cuối hàng; sau khi đọc hết từ thì không có vòng xả nên phần còn lại trong hàng không bao giờ được in. Vì hàng đợi vào trước ra trước, thứ tự in trùng đúng thứ tự nạp. Chạy tay theo đúng thứ tự ký tự của từ: nạp H, o, w, A, r, e; hai dấu sao in H rồi o; nạp Y, o, u; hai dấu sao in w rồi A; nạp T, o; hai dấu sao in r rồi e; cuối cùng nạp D, a, y mà không còn dấu sao nào. Sáu dấu sao in ra đúng sáu ký tự được nạp sớm nhất: H, o, w, A, r, e. "HowAr" chỉ có năm ký tự, tức đếm thiếu một dấu sao. "owAreY" bỏ chữ H dù H vào hàng sớm nhất nên phải ra trước nhất. "erAwoH" 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