问题 问答题

请编写一个函数fun(),它的功能是:将ss所指字符串中所有下标为偶数位置的字母转换为小写(若该位置上不是字母,则不转换)。 例如,若输入ABC4efG,则应输出aBc4efg。 注意:部分源程序给出如下。 请勿改动主函数miain和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include<conio.h> #include<stdio.h> #include<string.h> void fun(char *ss) { } main() { char tt[81]; clrscr(); printf("\nPlease enter an string within 80 characters:\n"); gets(tt); printf("\n\nAfter changing,the string\n \%s",tt); fun(tt); printf("\nbecomes\n \%s\n",tt); }

答案

参考答案:

解析:void fun(char *ss) { int i; for(i=0;ss[i]!=’\0’i++) /*将ss所指字符串中所有下标为偶数位置的字母转换为小写*/ if(i%2==0&&ss[i]>=’A’&&ss[i]<=’z’) ss[i]=ss[i]+32; } 从C语言的学习中我们知道,只要将小写字母减去32则转成大写字母,将大写字母加上32则转成小写字母。该程序是用if语句实现该功能转化的。

阅读理解

Busy as I am every day, I always open my computer and check my email. Most of the time I am simply doing finger exercises, another form of piano practice without beautiful tones. Sometimes, however, I receive a gift, reminding me of the gifts in my life. The following passage is one of those gifts.

Peter Jones is a 92-year-old, short, calm and proud man. Every morning he is fully dressed by eight o’clock, with his hair fashionably combed and face perfectly shaved even though hi is unable to see anything. He would move to a nursing home today. His wife of 70 years old has recently passed away, making the move necessary.

After hours of waiting patiently in the entrance hall of the nursing home, he smiled sweetly when told his room was ready. As he moved his walking stick skillfully to the elevator, the nurse provided a visual description of his tiny room. “I love it,” he stated with enthusiasm. “Mr. Jones, you haven’t been the room,” said the nurse.

“That doesn’t have anything to do with it,” he replied. “Happiness is something you decide on ahead of time. Whether I like my room or not doesn’t depend on how the furniture is arranged…it’s how I arrange my mind. I have already decided to love it. It’s a decision I make every morning when I wake up. I have a choice: I can spend the day in bed complaining of the difficulty I have with the parts of my body that no longer work, or get out of bed and be thankful for the ones that do.”

Each day is a gift, and as long as we are alive. We’ll focus on the new day and all the happy memories we’ve stored just as Mr. Jones does.

小题1:What do we know about Mr. Jones ?

A.He is a blind but very neat.

B.His wife died many years ago.

C.He likes playing the piano.

D.His room in the nursing home is big.小题2:How did Mr. Jones feel about his room in the nursing home?

A.worried

B.curious

C.disappointed

D.content小题3:The underlined word “it” in paragraph 4 refers to ________.

A.the furniture

B.the room

C.a decision

D.a gift小题4:What would be the best title for the text?

A.Each Day is a Gift

B.Be Always Grateful

C.Living in a nursing room

D.Arrange Your Mind Every Day

名词解释