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***g" ?
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: "gMoG". Mỗi dấu sao lấy bỏ một ký tự ở đỉnh ngăn xếp mà không in, các ký tự khác được đẩy vào; vòng cuối lấy ra lần lượt nên in theo thứ tự ngược với lúc nạp. Chạy tay theo đúng thứ tự ký tự của từ: nạp G, o, o, d rồi hai dấu sao lấy bỏ d và o, còn G, o; nạp M, o, r, n rồi hai dấu sao bỏ n và r, còn G, o, M, o; nạp i, n rồi ba dấu sao bỏ n, i và o, còn G, o, M; nạp g thành G, o, M, g. Vòng xả cho g, M, o, G. "gMoo" giả định ba dấu sao liền nhau chỉ lấy bỏ hai ký tự nên chữ o đẩy vào sau M vẫn còn; đếm đủ thì nó đã bị lấy. "gMor" giữ lại r, nhưng r đã bị dấu sao thứ tư lấy bỏ từ trước. "GoMg" chính là thứ tự nạp vào, trong khi ngăn xếp xả ra theo chiều vào sau ra trước.
Cùng phần 2
Consider the following pseudocode:
declare a queue of characters
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ó lời giảiCâu hỏiSuppose we are implementing a stack of Integers using a singly linked list where the head of the list is treated as the top of the stack.
Specify the correct implementation of push() method of the stack. (Choose the most suitable one)Có lời giảiCâu hỏiConsider the following pseudocode:
declare a queue of characters
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 "HowAre***You**To**Day " ?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