问题 单项选择题

有以下程序: #include <stdio.h> int fun(char s[]) { int n=0; while(*s<='9'&&*s>='0') {n=10*n+*s-'0';s++;} return(n); } main() { char s[10]={'6','1','*','4','*','9','*','0','*'};printf("%d\n",fun(s)); } 程序的运行结果是( )。

A.9

B.61490

C.61

D.5

答案

参考答案:C

解析: 题目fun()函数中while循环的意思是:判断s所指内容是否为数字字符,如果是数字字符,则计算表达式n=10*n+*s-'0';。其中*s-'0'的作用是将相应的数字字符转换为数值,例如字符'8'减去字符'0'后,得到的结果就是数值8了。n=10*n+的作用是将累计变量n中原来内容乘以10,然后再加上刚转换的数字字符的数值,例如原来n的值为1,*s现在的内容为'2',那么执行了n=10*n+*s-'0';语句后,n的值变为12,如果接下来再来一个'8'字符,执行n=10*n+*s-'O';语句后,n的值就是128了。故不难看出fun()函数的作用是“将数字字符串转换为相应的十进制数值,碰到非数字字符时结束”。从主函数中定义的字符数组s的初始化内容可以看出,fun()函数返回值应该是61。故应该选择C。

阅读理解

Walt Disney began to make cartoon movies when he was young. But he didn’t have much money and he didn’t always have enough to eat. One day a mouse ran near his desk when he worked in his small office.

“Would you like to be my pet? ”Disney asked the mouse. He caught the mouse and kept it as a pet. A few years later, Disney decided to make a cartoon about it. “I am making a cartoon about a mouse named Mortimer,” he told his wife. “Mortimer Mouse? I think Mickey Mouse would be a better name.” She said. “You are right!”  Disney agreed and made many Mickey Mouse cartoons.

People all over the world saw Mickey and loved it. Mickey Mouse made Disney famous. Then come Donald Duck, and Goofy Dog and others. Disney began to make full length (长) cartoons. Then he made cartoon movies for television. Millions of children watched the shows every week.

In California, real boats, castles (城堡), trains, mountains, rivers, all in one beautiful park. Millions of people came to Disneyland. He died in 1966, but the world will not forget him quickly. Mickey Mouse and all his cartoons will help us to remember him.

小题1:When Disney began making cartoon movies,          .

A.he was very poor

B.the mouse helped him

C.his wife knew nothing about it

D.People didn’t like Cartoons at all小题2:This passage mainly tells us       .

A.how Disney make Cartoon movies

B.how Disney built Disneyland

C.something about Disney’s childhood

D.something about Disney’s life小题3:Which of the flowing sentences is true?

A.Disney’s wife asked him to make a cartoon about the mouse.

B.Mickey Mouse was the name suggested by Disney’s wife.

C.Disney caught a mouse and made a cartoon about it at once.

D.People will remember Disney because of the Disneyland.

选择题