-->
当前位置:首页 > 题库

PROGRAMMING:JMU DS stack and queue small synthesis of stack, queue and string

Luz5年前 (2021-05-10)题库436
**Stack and queue are used to process each character in the string one by one**
Put the characters in line into the stack in turn, and then output the number of elements in the stack and the top elements of the stack.
Enter a character x (character to be deleted). Then, the elements in the stack are out of the stack in turn and output. When out of the stack, the characters not equal to X are put into the queue in turn and separated by spaces.
Output the number of queue elements, the head and tail of the queue, separated by spaces.
Finally, all the elements in the queue are output.
###Input format:
Input a string, input a character x (character to be deleted)
###Output format:
Number of elements in stack top elements
Eligible elements in the stack (separated by spaces)
Number of elements in the queue head element tail element
All elements in the queue (separated by spaces)
###Input example:
```in
ThisIsATest s
```
###Output example:
```out
11 t
tseTAsIsihT
8 t T
teTAIihT
```






answer:If there is no answer, please comment