Consider the following pseudocode: declare a stack 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 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***gSir" ?
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: "riSgMoG". Ngăn xếp lấy ra phần tử mới nhất. Nạp G, o, o, d rồi hai dấu sao lấy ra d và o, còn G, o; nạp M, o, r, n rồi hai dấu sao lấy ra n và r, còn G, o, M, o; nạp i, n rồi ba dấu sao lấy ra n, i, o, còn G, o, M; nạp g, S, i, r nên ngăn xếp từ đáy lên là G, o, M, g, S, i, r. Vòng cuối lấy ra và in từ đỉnh xuống đáy, cho r, i, S, g, M, o, G, tức riSgMoG. Dãy "riSgMoo" cần đáy là hai chữ o, nhưng chữ o thứ hai đã bị dấu sao thứ hai trong Good lấy ra. Dãy "riSgMor" kết thúc bằng r, trong khi r vừa được in đầu tiên vì nó ở đỉnh, không thể đồng thời nằm ở đáy. Dãy "GoMg" đọc từ đáy lên và rụng mất bốn ký tự, đó là trật tự của hàng đợi chứ không phải ngăn xếp.
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