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 and write the dequeued character to the screen
else
enqueue the character into the queue
}What is written to the screen for the input "Goo**dAft***erno*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: "GoodAf". Hàng đợi vào trước ra trước, nên mỗi dấu sao lấy ra phần tử được nạp sớm nhất còn lại. Chuỗi vào lần lượt là G, o, o, hai dấu sao, d, A, f, t, ba dấu sao, e, r, n, o, một dấu sao, o, n. Chạy theo đó: nạp G, o, o; hai dấu sao lấy ra G rồi o, in được Go; nạp d, A, f, t; ba dấu sao kế tiếp lấy ra o, d, A, in thêm odA; nạp e, r, n, o; dấu sao tiếp theo lấy ra f, in thêm f; hai ký tự o và n cuối chỉ được nạp vào mà không còn dấu sao nào kéo ra. Chuỗi in ra là G, o, o, d, A, f tức GoodAf. Phương án "fAdooG" là đúng dãy ấy đọc ngược, ứng với việc dùng ngăn xếp vào sau ra trước thay cho hàng đợi. Phương án "GoodAT" và phương án "GoodAE" đều đúng năm ký tự đầu rồi sai ký tự thứ sáu: sau khi G, o, o, d, A đã ra, phần tử vào sớm nhất còn lại là f, vì f được nạp trước cả t và e.
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