计算机二级C语言上机试题100套及答案

上传人:pu****.1 文档编号:505061277 上传时间:2023-04-14 格式:DOC 页数:331 大小:1.52MB
返回 下载 相关 举报
计算机二级C语言上机试题100套及答案_第1页
第1页 / 共331页
计算机二级C语言上机试题100套及答案_第2页
第2页 / 共331页
计算机二级C语言上机试题100套及答案_第3页
第3页 / 共331页
计算机二级C语言上机试题100套及答案_第4页
第4页 / 共331页
计算机二级C语言上机试题100套及答案_第5页
第5页 / 共331页
点击查看更多>>
资源描述

《计算机二级C语言上机试题100套及答案》由会员分享,可在线阅读,更多相关《计算机二级C语言上机试题100套及答案(331页珍藏版)》请在金锄头文库上搜索。

1、上 机 题 库第一部分 填空题注意:源程序存放在考生文件夹下的BLANK1.C中。1. 不得增行或删行,也不得更改程序的结构!2. 请在程序下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。1. 给定程序中,函数FUN的功能是:计算出带有头接点的单向链表中各结点数据域之和作为函数值返回。#include #include #define N 8typedef struct list int data;struct list *next; SLIST;SLIST *creatlist(int *);void outlist(SLIST *);int fun( SLIST *h) SLI

2、ST *p; int s=0;p=h-next;while(p)/*found*/s+= p-_1_; data/*found*/p=p-_2_; nextreturn s;main( ) SLIST *head;int aN=12,87,45,32,91,16,20,48;head=creatlist(a); outlist(head);/*found*/printf(nsum=%dn, fun(_3_); headSLIST *creatlist(int a ) SLIST *h,*p,*q; int i;h=p=(SLIST *)malloc(sizeof(SLIST);for(i=0;

3、 idata=ai; p-next=q; p=q;p-next=0;return h;void outlist(SLIST *h) SLIST *p;p=h-next;if (p=NULL) printf(The list is NULL!n);else printf(nHead );do printf(-%d, p-data); p=p-next; while(p!=NULL);printf(-Endn);2. 给定程序中,函数FUN的功能是:求出形参SS所指字符串数组中最长字符串的长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中工有M个字符串,且串长N。#includ

4、e #include #define M 5#define N 20void fun(char (*ss)N) int i, j, k=0, n, m, len;for(i=0; in) /*found*/n=len; k=_1_; i for(i=0; i=0; j-) lenssim-=ssij;for(j=0; jn-len; j+)/*found*/ssij=_3_; *main( )char sMN=shanghai,guangzhou,beijing,tianjing,cchongqing;int i;printf(nThe original strings are :n);for

5、(i=0; iM; i+) printf(%sn,ssi);printf(n);fun(ss);printf(nThe result:n);for(i=0; iM; i+) printf(%sn,ssi);3. 人员记录由编号和出生年,月,日组成,N名人员的数据已在主函数中存入结构体数组std且编号唯一。函数fun 的功能是;找出指定编号人员的数据,作为函数值返回,有主函数输出,若指定编号不存在,返回数据中的编号为空串。#include #include #define N 8typedef struct char num10;int year,month,day ;STU;/*found*/

6、_1_fun(STU *std, char *num) STU int i; STU a=,9999,99,99;for (i=0; iN; i+)/*found*/if( strcmp(_2_,num)=0 ) stdi.num/*found*/return (_3_); stdireturn a;main( )STU stdN= 111111,1984,2,15,222222,1983,9,21,333333,1984,9,1,444444,1983,7,15,555555,1984,9,28,666666,1983,11,15,777777,1983,6,22,888888,1984,8

7、,19;STU p; char n10=666666;p=fun(std,n);if(p.num0=0)printf(nNot found !n);else printf(nSucceed !n );printf(%s %d-%d-%dn,p.num,p.year,p.month,p.day);4. 给定程序中已建立一个带有头结点的单向链表,链表中的各结点按数据域递增有序链接。函数fun 的功能:删除链表中数据域值相同的结点,使之保留一个。#include #include #define N 8typedef struct list int data;struct list *next; S

8、LIST;void fun( SLIST *h) SLIST *p, *q;p=h-next;if (p!=NULL) q=p-next;while(q!=NULL) if (p-data=q-data) p-next=q-next;/*found*/free(_1_); q/*found*/q=p-_2_; nextelse p=q;/*found*/q=q-_3_; nextSLIST *creatlist(int *a) SLIST *h,*p,*q; int i;h=p=(SLIST *)malloc(sizeof(SLIST);for(i=0; idata=ai; p-next=q; p=q;p-next=0;return h;void outlist(SLIST *h) SLIST *p;p=h-next;if (p=NULL

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号