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 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*Mor**ni***ngSir" ?
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: "riSgnooG". Dấu sao chỉ lấy bỏ ký tự ở đỉnh mà không in, phần in dồn vào vòng xả cuối nên thứ tự ra ngược với thứ tự nạp. Chạy tay theo đúng thứ tự ký tự của từ: nạp G, o, o, d rồi một dấu sao bỏ d, còn G, o, o; nạp M, o, r rồi hai dấu sao bỏ r và o, còn G, o, o, M; nạp n, i rồi ba dấu sao bỏ i, n và M, còn G, o, o; nạp n, g, S, i, r. Ngăn xếp cuối cùng tính từ đáy lên là G, o, o, n, g, S, i, r nên xả ra cho r, i, S, g, n, o, o, G. "riSgnoGo" đổi chỗ hai ký tự dưới đáy, nhưng G nạp đầu tiên nên bắt buộc ra sau cùng. "riSgnooS" để S ở đáy dù S chỉ được nạp một lần, ở gần cuối từ. "riSgnooGi" dài chín ký tự, thừa một so với tám ký tự còn lại trong ngăn xếp. "GMongS" đi theo chiều nạp vào và còn giữ M, chữ đã bị dấu sao thứ sáu lấy bỏ.
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