问题 单项选择题

若有以下程序段; #include<iostream> using namespace std; int main() {int a[]={1,4,5};int *p=&a[0],x=6,y,z;for(y=0;y<3;y++) z=((*(p+y)<x) *(p+y):x);cout<<z<<end1;return 0; } 程序运行后的输出结果是( )。

A.1

B.4

C.5

D.2

答案

参考答案:C

解析: 本题考核指针的运算。 ①程序首先定义了一整型数组a,并赋初值1,4,5。即a[0],a[1]和a[2]的值分别为1,4和5。程序还定义了一个整型指针p,并初始化它指向数组元素a[0]。 ②在for循环语句中,赋值语句“z=((*(p+y)<x)*(p+y):x);”可等价为:“z=(aly]<x)a[y]:x”。因为表达式中的“*(p+y)=p[y]=a[y]”。 ③for语句每循环一次,就给变量z重新赋值一次,z的值其实就是数组和x相比较,将数组a中的最大值赋给z。当y=2后,退出循环,输出结果是5。

阅读理解

This is a true story from Guyana. One day, a boy took a piece of paper from a box. He made a paper ball and pushed it into his nose. He couldn’t get it out. He ran crying to his mother. His mother couldn’t get the paper out, either. A week later, the paper was still in the boy’s nose. His nose began to have a bad smell.

So his mother took the boy to a hospital. The doctor looked up at the child’s nose, but she couldn’t get the paper out. She said she had to cut the boy’s nose to get the paper out.

The boy’s mother came home looking sad. She didn’t want her child to have his nose cut. The next day she took the boy to her friend Sidney who lived in a house with an old lady called May. May wanted to see the child, so the child let her look up his nose.

“Yes, I can see it,” May said. “It will be out soon.”

As she spoke, she shook some black pepper on the child’s nose. The child gave a mighty sneeze and the paper flew out. His mother was surprised. May told his mother to take the boy to the seaside for a swim, for the salt water would go up his nose and stop the bad smell.

So the lucky boy didn’t have to go to the hospital to have his nose cut.

小题1: After the boy pushed a paper ball into his nose, ____.

A.he took it out

B.his mother took it out

C.he did nothing but cry

D.he tried to take it out but failed小题2:The paper ball stayed in the boy’s nose for ____.

A.at most seven days

B.less than seven days

C.more than seven days

D.exactly seven days、小题3: Which of the following is TRUE?

A.The doctor helped to take the paper ball out of the boy’s nose.

B.May succeeded in taking the paper out.

C.The boy’s mother found some black pepper to solve the problem.

D.The boy had to have his nose cut at last.小题4:The boy should be taken to the seaside for a swim because ____.

A.he needed to learn to swim

B.the sea water would stop the bad smell of his nose.

C.the sea water would wash out the paper ball.

D.he needed a rest

单项选择题