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 "Goo***dAft**er**no**on" ?
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: "noon". Ở đoạn mã này dấu sao chỉ lấy ra rồi bỏ đi mà không in; chỉ khi đọc hết chuỗi mới lần lượt lấy ra và in phần còn lại theo lối vào trước ra trước. Nạp G, o, o rồi ba dấu sao bỏ sạch cả ba; nạp d, A, f, t rồi hai dấu sao bỏ d với A, còn f, t; nạp e, r rồi hai dấu sao bỏ f với t, còn e, r; nạp n, o rồi hai dấu sao bỏ e với r, còn n, o; cuối cùng nạp o, n mà không còn dấu sao nào, nên hàng đợi giữ n, o, o, n. Chuỗi "fterno" dài sáu ký tự và còn giữ f, t, hai ký tự đã bị cặp dấu sao ngay sau chúng loại đi. Chuỗi "ternoo" cũng dài sáu, giữ t cùng e, r, trong khi e, r đã bị cặp dấu sao kế tiếp lấy ra. Chuỗi "ernoo" dài năm ký tự, giữ e, r rồi nối n, o, o mà đánh rơi n nạp sau cùng; chuỗi vào có 13 chữ cái và 9 dấu sao nên hàng đợi phải còn đúng bốn ký 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