问题 单项选择题

A.栈为空却要进行出栈操作

B.栈已满却要进行入栈操作

C.表达式处理已结束,栈中仍留有字符“(”

D.表达式处理已结束,栈中仍留有字符“)”

答案

参考答案:A

解析:(33)~(34)

[分析]: 对算术表达式(a+b*(a+b))/c)+(a+b)进行括号检查时,栈操作的顺序为: 入栈,入栈,出栈,出栈,出栈,…… 当需要进行第三次出栈操作时,发现栈已空,已不可能完成出栈操作。 对算术表达式((a+b/(a+b)-c/a)/b进行括号检查时,栈操作的顺序为: 入栈,入栈,入栈,出栈,出栈 第1次出栈操作取出的是第3次刚入栈的“(”,第2次出栈操作取出的是第2次入栈的“(”。直到表达式检查结束,第1次入栈的“(”仍没有取出,因此,表达式中的括号并不匹配。 本例是栈的重要应用之例。编译程序中常用栈来检查语句(或程序)中的括号是否匹配。 在日常生活中,当人们进入一个复杂的大院时,需要多次进门,多次出门。每次出门,总是退出最近进门的院。在同一位置堆积货物时,总是先取最近刚放上的货。所以,栈的应用也是比较常见的。可以用这种日常生活中的例子来形象地理解栈的操作。

阅读理解

Last July, my 12-year-old car died on California's Santa Freeway. It was an hour before sunset, and I was 25 miles from home. I couldn't reach anyone to pick me up, so I decided to take a bus. Not knowing the routes, I thought I'd just go east.

A bus stopped. I got on and asked the driver how far she was going, "Ten more miles," she said. There was another bus I could take from there. This clearly was going to be a long night.

I got off at the end of the route and she told me which bus to look for. After waiting 30 minutes, I began to think about a very expensive taxi ride home. Then a bus came up. There was no lighted number above its windshield. It was out of service, but the door opened. It was the same driver.

“I just can't leave you here,” she said. “This isn't the nicest place. I will give you a ride home.”

“You will drive me home on the bus?" I asked, astonished.

“No, I will take you in my car,” she said.

“It's a long way," I insisted.

“Come on, ” she said. “I have nothing else to do.”

As we drove from the station in the car, she began telling me a story, A few days earlier, her brother had run out of gas. A good man picked him up, took him to a service station and then back to his car. “I'm just passing the favor(善意的行为) along,” she said.

When I offered her money as a thank-you, she wouldn't accept. “Just do something nice for somebody. Pass it along," she said.

小题1:There was something wrong with the writer's car ______.

A.late at night

B.early in the morning

C.an hour before sunset

D.thirty minutes after sunset小题2:The writer changed his mind after waiting 30 minutes because ______.

A.he became impatient and a bit worried

B.a taxi ride would be more comfortable

C.he knew the driver would never return

D.the bus driver had given him wrong information小题3:The bus driver drove the writer home later because ______.

A.her brother had told her to do so

B.she wanted to earn more money

C.she happened to go in the same direction

D.she wanted to do something good for others小题4:The underlined word "astonished" in the passage probably means      .

A.surprised

B.grateful

C.happy

D.angry小题5:The bus driver hoped that the writer       .

A.would drive someone home

B.would help someone in need

C.would keep her in memory

D.would give the money to others

多项选择题