二级C语言上机填空题技巧总结.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《二级C语言上机填空题技巧总结.doc》由会员分享,可在线阅读,更多相关《二级C语言上机填空题技巧总结.doc(19页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、如有侵权,请联系网站删除,仅供学习与交流二级C语言上机填空题技巧总结【精品文档】第 19 页上机填空题技巧总结一、 填空题之方法1. 上机填空题占30分,一般有3个空需要填写,每个空为10分;2. 填空题做题之前必须弄清题目含义,抓住关键字,例如:要求对数组进行从小到大排序,则将会出现大于符号,如果是从大到小排序则出现小于符号;3. 填空题中出现频率最高的就是函数的调用、函数的首部、函数的返回值等和函数相关的问题,因此必须牢牢掌握祝函数的基本特征;4. 填空题中有的“空”比较难,考生除了掌握必须的C语言知识之外,还需要很好的逻辑思路,如果一个空将花很多时间来解决,那么建议使用“死记硬背”的方法
2、来缩短复习时间;5. 上机题库中100题有部分题目是重复的或是相似的题目很多,同学们要使用比对的方法尽量去理解;6. 多练习,多思考,多总结二、 填空题与结构体相关1. 结构体成员引用:上机题库P18第9题(和92题一致),P27第23题(和51题一样)读清楚题目要求:(1) 要求将形参a所指结构体变量的数据赋值给函数中的结构体变量b(2) 从例如可以看出来:结构体中的学号和姓名变为了1002和“LiSi”,但是3门课成绩没有变化#include #include struct student long sno; char name10; float score3;void fun(struc
3、t student a) struct student b; int i;/*found*/ b = _1_;题目要求将形参a的值赋值给结构体变量b,因此填:a b.sno = 10002;学号变为了10002/*found*/ strcpy(_2_, LiSi);姓名要变为”LiSi”,则要引用b中的name成员 printf(nThe data after modified :n);/*讲解是一句带过不用多讲*/ printf(nNo: %ld Name: %snScores: ,b.sno, b.name); /*讲解是一句带过不用多讲*/*found*/ for (i=0; i3; i
4、+) printf(%6.2f , b._3_);分析:这个是一个循环语句,执行3次循环,printf(%6.2f , b._3_)要求输出是一个实型数据的成员,因此可以得知是score成员,因为score是一个数组,因此填:b.scorei,当i变化就可以取出第一门、第二门、第三门课的成绩 printf(n);main() struct student s=10001,ZhangSan, 95, 80, 88; int i; printf(nnThe original data :n); printf(nNo: %ld Name: %snScores: ,s.sno, s.name); fo
5、r (i=0; i3; i+) printf(%6.2f , s.scorei); printf(n); fun(s);23题:(1) 从例如中可以看出:变化的是结构体中的学号和姓名#include #include struct student long sno; char name10; float score3;void fun( struct student *b) int i;/*found*/ b_1_ = 10004;题目中t的学号变化为了10004,因此填写:b-sno,不能填写b.sno,因为b是一个指针/*found*/ strcpy(b_2_, LiJie);t的姓名变为
6、了”LiJie”,因此填写:b-namemain() struct student t=10002,ZhangQi, 93, 85, 87; int i; printf(nnThe original data :n); printf(nNo: %ld Name: %snScores: ,t.sno, t.name); for (i=0; i3; i+) printf(%6.2f , t.scorei); printf(n);/*found*/ fun(_3_);此处为函数调用,根据形参的类型来判定实参,形参struct student *b为结构体指针,联系main函数定义部分只有struct
7、 student t和b的类型相同,因此可知需要填的是:&t printf(nThe data after modified :n); printf(nNo: %ld Name: %snScores: ,t.sno, t.name); for (i=0; i3; i+) printf(%6.2f , t.scorei); printf(n);2. 函数调用and结构体:上机题库P22第16题(和78、82题一样)重点注意:(1)把a中地址作为函数返回值返回函数(2)观察可知a中的学号、姓名边为了10002和“zhangSan”,每门课的成绩增加了1分#include #include stru
8、ct student long sno; char name10; float score3;/*found*/_1_ fun(struct student *a)根据函数调用t = fun(&s);可知函数返回类型和t的类型相同,struct student s=10001,ZhangSan, 95, 80, 88, *t;可知t的类型为struct student * int i; a-sno = 10002; strcpy(a-name, LiSi);/*found*/ for (i=0; iscorei,不能为a.scorei或是a.score/*found*/ return _3_
9、;题目要求返回a的地址,a本身就是一个指针,因此填入a即可main() struct student s=10001,ZhangSan, 95, 80, 88, *t; int i; printf(nnThe original data :n); printf(nNo: %ld Name: %snScores: ,s.sno, s.name); for (i=0; isno, t-name); for (i=0; iscorei); printf(n);3. 结构体和排序:上机题库P14第2题 重点注意:(1)排序的格式:红色部分为考试中的重点,必须记住从小到大排序:for(i=0;in-1;
10、i+)for(j=i+1;jaj) t=ai;ai=aj;aj =t;从大到小排序:for(i=0;in-1;i+)for(j=i+1;jn;j+) if(aiaj) t=ai;ai=aj;aj =t; void fun(struct student a, int n)/*found*/ _1_ t;此处要求填入t的类型,可以从t = ai;中得知t和a数组的类型必须一致,void fun(struct student a, int n)中得知a为结构体类型,因此填写:struct student int i, j;/*found*/ for (i=0; i_2_; i+)根据排序的格式填空,
11、因此记住是关键 for (j=i+1; j 0)按照姓名字典顺序从小到大排序,因此:strcmp(ai.name,aj.name),此处需要特别注意 t = ai; ai = aj; aj = t; main() struct student s4=10001,ZhangSan, 95, 80, 88,10002,LiSi, 85, 70, 78, 10003,CaoKai, 75, 60, 88, 10004,FangFang, 90, 82, 87; int i, j; printf(nnThe original data :nn); for (j=0; j4; j+) printf(nN
12、o: %ld Name: %-8s Scores: ,sj.sno, sj.name); for (i=0; i3; i+) printf(%6.2f , sj.scorei); printf(n); fun(s, 4); printf(nnThe data after sorting :nn); for (j=0; j4; j+) printf(nNo: %ld Name: %-8s Scores: ,sj.sno, sj.name); for (i=0; inext,上机题库P21第15题考点分析:(1)带头结点链表的表现形式:headabcABCNULL带头结点的链表,头结点head不存
13、放任何的数据,从头结点的下一个结点开始存放数据,因此考试中如果出现 p = _1_ ;则填入p=h-next(2)链表数据排序对数组元素从小到大排序:for(i=0;in-1;i+)for(j=i+1;jaj) t=ai;ai=aj;aj =t;对链表元素进行从小到大排序:while (p) /*相当于数组排序中的for(i=0;inext;/*相当于j=i+1*/ while (q) /*相当于for(;jdata q-data) /*相当于if(aiaj)*/ t = p-data; p-data = q-data; q-data = t; /*如果aiaj成立,则交换数据元素,让数据变成
14、从小到大排序*/ q = q-next;/*相当于q+*/ p = p-next;/*相当于p+*/ 15题:#include #include #define N 6typedef struct node int data; struct node *next; NODE;void fun(NODE *h) NODE *p, *q; int t;/*found*/ p = _1_ ;链表为带头结点,因此填写:p=h-next while (p) /*found*/ q = _2_ ;比较两个链表中元素的大小,因此q=p-next,这样q指向了p的下一位 while (q) /*found*/
15、 if (p-data _3_ q-data)从小到大排序,因此使用大于符号,填写: t = p-data; p-data = q-data; q-data = t; q = q-next; p = p-next; main() NODE *head; int aN= 0, 10, 4, 2, 8, 6 ; head=creatlist(a); printf(nThe original list:n); outlist(head); fun(head); printf(nThe list after sorting :n); outlist(head);2. 不带头结点的链表:p=h(1) 不
16、带头结点链表的表示形式:abcABCNULL不带头结点的链表没有头结点,链表的第一个结点存储的就是数据,因此考试中如果出现 p = _1_ ;则填入p=h(2) 讲解P38第42题(和15题类似)void fun(NODE *h) NODE *p, *q; int t; p = h;不带头结点的链表 while (p) /*found*/ q = _1_ ;q指向p的下一位,因此填入:q=p-next/*found*/ while (_2_)判断q有没有到末尾,因此填入p或是p!=NULL if (p-data q-data) t = p-data; p-data = q-data; q-da
17、ta = t; q = q-next; /*found*/ p = _3_ ; while (p)为循环条件,要构成循环p就得自加或是自减,从循环体中得知没有进行p+之类的操作,因此此处填入:p=p-next或是p+ main() NODE *head; int aN= 0, 10, 4, 2, 8, 6 ; head=creatlist(a); printf(nThe original list:n); outlist(head); fun(head);3. 链表的返回值:P43第50题(和43题类似)/*found*/_1_ fun(NODE *h)根据函数调用head=fun(head)
18、;和 NODE *head; 知道函数的返回值为NODE * NODE *p, *q, *r; p = h; if (p = NULL)如果p数据位空,则表示p中没有任何的数据,因此就无需再进行逆置,故return NULL; return NULL; q = p-next; p-next = NULL;/*found*/ while (_2_)此空判断q有没有为空,讲解时候不容易理解,考生记住即可,填入:while(q)或是while(q!=NULL) r = q-next; q-next = p; p = q;/*found*/ q = _3_ ;填入:q=r;次空理解起来较难,因此考生必
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 二级 语言 上机 填空 技巧 总结
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内