[计算机类试卷]国家二级C语言机试(操作题)模拟试卷576及答案与解析.doc

上传人:ownview251 文档编号:498541 上传时间:2018-11-29 格式:DOC 页数:6 大小:31KB
下载 相关 举报
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷576及答案与解析.doc_第1页
第1页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷576及答案与解析.doc_第2页
第2页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷576及答案与解析.doc_第3页
第3页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷576及答案与解析.doc_第4页
第4页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷576及答案与解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 576及答案与解析 一、程序填空题 1 下列给定程序中,函数 fun的功能是:在带头结点的单向链表中,查找数据域中值为 ch的结点。找到后通过函数值返回该结点在链表中所处的顺序号;若不存在值为 ch的结点,函数返回 0值。 请在程序的下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构 ! 试题程序: #include stdio h #include stdlib h #define N 8 typedef struct list int data; struct list*ne

2、xt; SLIST; SLIST*creatliSt(char*); void outlist(SLIST*); int fun(SLIST*h, char ch) SLIST*p; int n=0; p=h一 next; *found* while(p!=【 1】 ) n+; *found* if(p一 data=ch) return 【 2】 ; else p=p一 next; return 0; main() SLIST*head; int k; char ch; char aN=m, p, g, a, w, x, r, d; head=creatlist(a); outlist(hea

3、d); printf(“Enter a letter: “); Scanf(“ c“, &ch); *found* k=fun(【 3】 ); if(k=0) printf(“ nNot found! n“); elSe printf(“The sequence number is: d n“, k); SLIST*creatlist(char*a) SLIST*h, *p, *q; int i; h=P=(SLIST*)malloc(si。 zeof(SLIST); for(i=0; i N; i+) q=(SLIST*)malloc(sizeof(SLIST); q一 data=ai; p

4、一 next=q; p=q; p一 next=0; return h; void outliSt(SLIST*h) SLIST *p; p=h一 next; if(p=NULL) printf(“ nThe list is NULL! n“), else printf(“ nHead“); do printf(“一 c“, p一 data); p=p一 next; while(p!=NULL); printf(“一 End n“); 二、程序修改题 2 下列给定程序中,函数 fun的功能是:删除指针 P所指字符串中的所有空白字符(包括制表符、回车符及换行符 )。 输入字符串时用 “#”结束输入

5、 请改正程序中的错误,使它能输出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改 程序的结构 ! 试题程序: #include string h #include stdio h #include ctype h fun(char*p) int i, t; char C80; *found* For(i=0, t=0; pi; i+) if(!isspace(*(P+i) Ct+=pi; *found* ct=“ 0“; strcpy(p, c); void main() char c, s80; int i=0; printf(“Input a string: “);

6、 C=getchar(); while(c!=#) si=c; i+; c=getchar(); si= 0; fun(s); puts(s); 三、程序设计题 3 编写函数 fun,其功能是:将 SS所指字符串中所有下标为奇数位上的字母转换为大写 (若该位置上不是字母,则不转换 )。 例如,若输入 “abc4EFg”,则应输出 “aBc4EFg”。 注意:部分源程序给出如下。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 试题程序: #include conio h #include stdio h #include string h vo

7、id fun(char*ss) void main(void) char tt51; printf(“ nPlease enter an character string within 50 characters: n“); gets(tt); printf(“ n nAfter chan- ging, the string n s“, tt); fun(tt); printf(“ nbecomes n s“, tt); 国家二级 C语言机试(操作题)模拟试卷 576答案与解析 一、程序填空题 1 【正确答案】 (1)NULL (2)n (3)head, ch 【试题解析】 填空 1: whi

8、le循环语句用来判断是否到达链表结尾,链表结尾结点指针域是 NULL。 填空 2:若找到指定字符,则通过 return语句将该结点在链表的顺序号返回给main函数。 填空 3:函数调用语句,其形式是:函数名 (实际参数表 ),因此根据函数定义语句,填入 head, ch。 二、程序修改题 2 【正确答案】 (1)for(i=0, t=0; pi; i+) (2)ct= 0; 【试题解析】 该题目考查 c语言关键字的书写, c语言中关键字是区分大小写的。另外为字符串结尾添加结束符时应书写为 0,而非 “ 0”, “ 0”表示一个字符串。该程序的 if条件中应用了 isspace函数,该 函数的功能是检查 ch是否为空格、跳格符 (制表符 )或换行符。 三、程序设计题 3 【正确答案】 void fun(char*ss) int i; for(i=0; ssi!= 0; i+) *将 ss所指字符串中所有下标为奇数位置的字母转换为大写 * if(i 2=1&ssi =a &ssi =z) ssi=ssi一 32; 【试题解析】 将指定字符串中奇数位置的字母转换为大写,首先需要判断奇数位置,再判断该位置字符是不是小写字母,如果是小写字母,则将小写 字母转换为大写字母。字母大小写转换操作中,只要将小写字母减去 32即可转换为大写字母。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2763-1998 Aerospace Series Steel FE-PL1504 (33CrMoV12) Air Melted Hardened and Tempered Bar for Machining De Less Than or Equal to 80 mm 1 200 MPa Less Than or Equal to .pdf AECMA PREN 2763-1998 Aerospace Series Steel FE-PL1504 (33CrMoV12) Air Melted Hardened and Tempered Bar for Machining De Less Than or Equal to 80 mm 1 200 MPa Less Than or Equal to .pdf
  • AECMA PREN 2764-1998 Aerospace Series Steel FE-PL1504 (33CrMoV12) Air Melted Hardened and Tempered Forgings De Less Than or Equal to 80 mm 1 200 MPa Less Than or Equal to Rm Less T.pdf AECMA PREN 2764-1998 Aerospace Series Steel FE-PL1504 (33CrMoV12) Air Melted Hardened and Tempered Forgings De Less Than or Equal to 80 mm 1 200 MPa Less Than or Equal to Rm Less T.pdf
  • AECMA PREN 2767-1988 Aerospace Series Steel FE-PL79 Carburized Hardened and Tempered 1180 Less Than or Equal to Rm Less Than or Equal to 1550 MPa Bar for Machining De Less Than or .pdf AECMA PREN 2767-1988 Aerospace Series Steel FE-PL79 Carburized Hardened and Tempered 1180 Less Than or Equal to Rm Less Than or Equal to 1550 MPa Bar for Machining De Less Than or .pdf
  • AECMA PREN 2768-1988 Aerospace Series Steel FE-PL79 Carburized Hardened and Tempered 1180 Less Than or Equal to Rm Less Than or Equal to 1550 MPa Forgings De Less Than or Equal to .pdf AECMA PREN 2768-1988 Aerospace Series Steel FE-PL79 Carburized Hardened and Tempered 1180 Less Than or Equal to Rm Less Than or Equal to 1550 MPa Forgings De Less Than or Equal to .pdf
  • AECMA PREN 2769-1988 Aerospace Series Steel FE-PL53S Hardened and Tempered 1030 Less Than or Equal to Rm Less Than or Equal to 1180 MPa Forgings De Less Than or Equal to 70 mm Issu.pdf AECMA PREN 2769-1988 Aerospace Series Steel FE-PL53S Hardened and Tempered 1030 Less Than or Equal to Rm Less Than or Equal to 1180 MPa Forgings De Less Than or Equal to 70 mm Issu.pdf
  • AECMA PREN 2770-1988 Aerospace Series Steel FE-PL53S Hardened and Tempered 1050 Less Than or Equal to Rm Less Than or Equal to 1220 MPa Sheet and Plate 0 5 Less Than or Equal to a .pdf AECMA PREN 2770-1988 Aerospace Series Steel FE-PL53S Hardened and Tempered 1050 Less Than or Equal to Rm Less Than or Equal to 1220 MPa Sheet and Plate 0 5 Less Than or Equal to a .pdf
  • AECMA PREN 2771-1988 Aerospace Series Steel FE-PL53S Hardened and Tempered 1100 Less Than or Equal to Rm Less Than or Equal to 1250 MPa Bar De Less Than or Equal to 110mm Issue P 1.pdf AECMA PREN 2771-1988 Aerospace Series Steel FE-PL53S Hardened and Tempered 1100 Less Than or Equal to Rm Less Than or Equal to 1250 MPa Bar De Less Than or Equal to 110mm Issue P 1.pdf
  • AECMA PREN 2772-1999 Aerospace Series Steel FE-PM3801 (X5CrNiCu17-4)Air Melted Solution Treated and Precipitation Treated Forgings a or D Less Than or Equal to 200 mm Rm Greater Th.pdf AECMA PREN 2772-1999 Aerospace Series Steel FE-PM3801 (X5CrNiCu17-4)Air Melted Solution Treated and Precipitation Treated Forgings a or D Less Than or Equal to 200 mm Rm Greater Th.pdf
  • AECMA PREN 2773-1999 Aerospace Series Steel FE-PM3801 (X5CrNiCu17-4) Consumable Electrode Remelted Solution Treated and Precipitation Treated Sheet and Strip a Less Than or Equal tt.pdf AECMA PREN 2773-1999 Aerospace Series Steel FE-PM3801 (X5CrNiCu17-4) Consumable Electrode Remelted Solution Treated and Precipitation Treated Sheet and Strip a Less Than or Equal tt.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1