问题 单项选择题

有以下程序:
#include<stdio.h>
main()
int c;
while((c=getchar())!='\n')
switch(c-'2')
case 1:putchar(c+4);
case 2:putchar(c+4);break;
case 3:putchar(c+4);
case 4:putchar(c+4);break;

printf("\n");

输入以下数据,<CR>代表一个回车符,
2743<CR>
程序的输出结果是( )。

A) 877
B) 966
C) 778
D) 766

答案

参考答案:A

解析: 本题通过一个while循环向键盘缓冲区读取字符,直到读到的字符是回车键结束循环。当读到的c为'2'时,c-'2'为0, switch语句中没有case 0:所以没有输出,继续读下一个;当c为'7'时,c-'2'=5,也没有输出;当c为'4'时,c-'2'=2,执行case 2:后面的语句输出一个字符c+4='4'+4='8';当c为'3'时,c-'2'=1,执行case 1:后面的语句,连续输出两次c+4='3'+4='7'。故程序输出结果是877,应该选择A。

完形填空
What’s the secret of being a great friend? Here are some tips to help you be a nice friend.
Laugh and cry together.
Laughing with a friend is the best, but sometimes it’s crying that brings you closer together. Don’t be afraid to be yourself with your friends. Share your true feelings—you may learn that your friends feel the same way. As a result, friends will understand each other better.
Be a thoughtful gift giver.
Gift-giving isn’t just for birthdays or holidays—it can be a fun way of making your friends feel special! But don’t buy expensive presents—be creative! Making things shows you care, because you put time and thought into your gifts. Bake him favorite cookies, write him a poem, or draw something special for him. Small thoughtful gifts, such as picking a flower for a friend who is sick, just might cheer him up.
Stand up for him.
It’s hard to watch someone laugh at a friend. But don’t just stand there, do something about it! You can find a creative way to solve the problem to make others look at your friend differently. Other times, you need to show your courage and support him—he needs you. It may be not easy, but it’s what a good friend should do!
How   to   Be   a   Great   Friend
Laugh and cry together.
1. Both laughing and 小题1: ________ can bring friends closer.
2. Sharing your true feelings with friends can help you understand each other better.
Be a thoughtful gift giver.
1. Giving friends gifts can make them feel小题2: ________.
2. You’d better make small gifts by yourself小题3: ________ buying expensive ones for your friends.
Stand up for him.
1. If your friends are 小题4: ________ at, you can find a creative way to help them.
2. Show your courage and 小题5: ________ your friends.
 
单项选择题