《电大1253+C语言程序设计A(7月)小抄参考1.doc》由会员分享,可在线阅读,更多相关《电大1253+C语言程序设计A(7月)小抄参考1.doc(8页珍藏版)》请在三一办公上搜索。
1、C语言程序设计A课程试卷(6)题 号一二三四五总 分得 分2011年7月考 一、单选题(每小题2分,共20分) 1. C语言程序中的基本功能模块为( )。 A. 表达式 B. 标识符 C. 语句 D. 函数 2. 逻辑表达式(x0 | y=5)的相反表达式为( )。A. x=0 | y!=5 B. x0 | y!=5 D. x0 & y=5 3. 循环体至少被执行一次的循环语句为( )。 A. for B. while C. do-while D. 任一种循环 4. 假定n的值为5,则表达式n+的值为( )。 A. 6 B. 5 C. 4 D. 7 5. 假定一个二维数组的定义为“int a3
2、4=3,4,2,8,6;”,则元素a20的值为( )。 A. 0 B. 2 C. 4 D. 6 6. 假定一个函数原型为“char* func(int n)”,则该函数的返回类型为( )。 A. int B. int* C. char D. char* 7. 假定a为一个字符数组名,则元素ai的指针访问方式为( )。 A. a+i B. *(a+i) C. &a+i D. *a+i 8. 假定有语句为“int *p=calloc(10+20,sizeof(int);”,则p所指向的动态数组中所包含的元素个数为( )。 A. 10 B. 20 C. 30 D. 40 9十进制数50表示成符合C语
3、言规定的八进制数为_。 A. 20 B. 32 C. 62 D. 062 10. 若要以读和写两种操作方式打开一个二进制文件,当文件不存在时返回打开失败信息,则选用的打开方式字符串为( )。 A. r+ B. ab+ C. rb+ D. wb+ 二、填空题(每小题2分,共26分) 1. 在一个C语言程序文件中,若要包含另外一个头文件或程序文件,则应使用的预处理命令为_。 2. 用于从键盘上为变量输入值的标准输入函数的函数名为_。 3. 假定一个枚举类型的定义为“enum RAab,ac,ad,ae;”,则ac的值为_。 4double类型的长度为_。 5. 执行“int x=45,y=13;p
4、rintf(%d,x/y);”语句序列后得到的输出结果为_。 6. 把表达式x=x+y转换成复合赋值表达式为_。 7. 假定x的值为5,则执行“a=(!x? 10: 20);”语句后a的值为_。 8. 假定一维字符指针数组的定义为“char* a8;”,则该数组占用的存储空间的字节数为_。 9. 假定二维数组的定义为“double aMN;”,则数组元素的行下标取值范围在_之间。 10. 空字符串的长度为_。 11. 在所有函数定义之外定义的变量,若没有被初始化则系统隐含对它所赋的初值为_。 12. 若p指向x,则_与x的表示是等价的。 13. 直接访问表达式(*fp).score所对应的间接
5、访问表达式为_。 三、写出下列每个程序运行后的输出结果(每小题6分,共30分) 1. #include void main() int i,j,k=0; for(i=0; i5; i+) for(j=i; j5; j+) k+; printf(%dn,k); 2. #include void main() int x=20; int i=2; while(ix) if(x%i=0) printf(%d ,i); x/=i; i+; 3. #include void main() int a8=76,63,54,95,40,75,90,66; int i, s=0; for(i=0; i=70
6、& ai=90) s+=ai; printf(s=%dn,s); 4. #include int WF(int x, int y) x=x+y; y+=x; return x+y; void main() int x=3, y=8; printf(%dn,WF(x,y); 5. #include int LA(int *a, int n) int i,s=0; for(i=0;in;i+) s+=ai; return s; void main() int a5=1,2,3,4,5; int b=LA(a,5)+LA(a+2,3); printf(b=%dn,b); 四、写出下列每个函数的功能(
7、每小题6分,共12分) 1. int WC(int a, int n, int k) int i, c=0; for(i=0;i=k) c+; return c; 函数功能: 2. void QA(struct Worker a, int n) int i; for(i=0; iscore三、写出下列每个程序运行后的输出结果(每小题6分,共30分)评分标准:根据答案正确程度酌情给分。 1. 15 2. 2 5 3. s=241 4. 30 5. b=27四、写出下列每个函数的功能(每小题6分,共12分)评分标准:根据答案叙述正确与完整程度酌情给分。 1. 统计并返回一维整型数组an中大于等于k
8、的值的个数。 2. 从键盘上为具有struct Worker类型的数组an输入n个记录。五、按题目要求编写函数(每小题6分,共12分)评分标准:根据函数编写的正确与完整程度酌情给分。 1. double Mean(double aMN,int m,int n) int i,j; double v=0.0; /1分 for(i=0; im; i+) for(j=0; jn; j+) v+=aij; /4分 v/=m*n; return v; /6分 /注:函数体的最后两行可以合并为一条返回语句:return v/=m*n 2. int MM(int a,int m) int i,x1,x2; x
9、1=x2=a0; /1分 for(i=1; ix1) x1=ai; /3分 if(aix2) x2=ai; /4分 /5分 return x1-x2; /6分 Winger Tuivasa-Sheck, who scored two tries in the Kiwis 20-18 semi-final win over England, has been passed fit after a lower-leg injury, while Slater has been named at full-back but is still recovering from a knee injury
10、 aggravated against USA.Both sides boast 100% records heading into the encounter but Australia have not conceded a try since Josh Charnleys effort in their first pool match against England on the opening day.Aussie winger Jarryd Hayne is the competitions top try scorer with nine, closely followed by
11、 Tuivasa-Sheck with eight.But it is recently named Rugby League International Federation player of the year Sonny Bill Williams who has attracted the most interest in the tournament so far.The Kiwi - with a tournament high 17 offloads - has the chance of becoming the first player to win the World Cu
12、p in both rugby league and rugby union after triumphing with the All Blacks in 2011.Id give every award back in a heartbeat just to get across the line this weekend, said Williams.The (lack of) air up there Watch mCayman Islands-based Webb, the head of Fifas anti-racism taskforce, is in London for t
13、he Football Associations 150th anniversary celebrations and will attend Citys Premier League match at Chelsea on Sunday.I am going to be at the match tomorrow and I have asked to meet Yaya Toure, he told BBC Sport.For me its about how he felt and I would like to speak to him first to find out what h
14、is experience was.Uefa hasopened disciplinary proceedings against CSKAfor the racist behaviour of their fans duringCitys 2-1 win.Michel Platini, president of European footballs governing body, has also ordered an immediate investigation into the referees actions.CSKA said they were surprised and dis
15、appointed by Toures complaint. In a statement the Russian side added: We found no racist insults from fans of CSKA. Baumgartner the disappointing news: Mission aborted.The supersonic descent could happen as early as Sunda.The weather plays an important role in this mission. Starting at the ground, c
16、onditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. It will climb higher than the tip of Mount
17、Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.The balloon will slowly drift to the edge of s
18、pace at 120,000 feet ( Then, I would assume, he will slowly step out onto something resembling an Olympic diving platform.They blew it in 2008 when they got caught cold in the final and they will not make the same mistake against the Kiwis in Manchester.Five years ago they cruised through to the fin
19、al and so far history has repeated itself here - the last try they conceded was scored by Englands Josh Charnley in the opening game of the tournament.That could be classed as a weakness, a team under-cooked - but I have been impressed by the Kangaroos focus in their games since then.They have been
20、concentrating on the sort of stuff that wins you tough, even contests - strong defence, especially on their own goal-line, completing sets and a good kick-chase. Theyve been great at all the unglamorous stuff that often goes unnoticed in the stands but not by your team-mates.It is as though their en
21、tire tournament has been preparation for the final.In Johnathan Thurston, Cooper Cronk, Cameron Smith and either Billy Slater or Greg Inglis at full-back they have a spine that is unmatched in rugby league. They have played in so many high-pressure games - a priceless asset going into Saturday.The Kiwis are a lot less experienced but winning a dramatic match like their semi-final against England will do wonders for their confidence.They defeated Australia in the Four Nations final in 2010 and the last World Cup, and know they can rise to the big occasion.