Consider the following pseudocode: declare a stack of characters
5 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 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**Mor*ni**ng*Sir"?
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: "doring". Ngăn xếp lấy ra ở đỉnh, nên mỗi dấu sao in chữ cái vừa đẩy vào gần nhất. Chạy tay: đẩy G, o, o, d rồi hai sao lấy d và o, in do; đẩy M, o, r rồi một sao lấy r, in r; đẩy n, i rồi hai sao lấy i và n, in in; đẩy n, g rồi một sao lấy g, in g. Sáu dấu sao cho đúng sáu chữ theo thứ tự d, o, r, i, n, g. "droino" sai vì nó muốn r ra thứ hai, nhưng ngay sau khi lấy d thì đỉnh ngăn xếp đang là o của cụm Good, mà r thậm chí chưa được đẩy vào. "droinG" sai vì chữ G nằm dưới cùng, muốn lấy được nó thì toàn bộ chữ phía trên phải bị lấy ra trước, trong khi dãy nhập chỉ có sáu dấu sao. "droion" sai vì nó đổi hai chữ cuối thành o rồi n, còn lần lấy thứ năm phải cho n của cụm ni và lần cuối cho g. "droinM" sai vì M bị o của cụm Mor và các chữ sau đè lên, nó chỉ ra được nếu còn thêm dấu sao sau khi đã lấy hết phần trên.
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