【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷362及答案解析.doc

上传人:brainfellow396 文档编号:1332176 上传时间:2019-10-17 格式:DOC 页数:2 大小:28.50KB
下载 相关 举报
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷362及答案解析.doc_第1页
第1页 / 共2页
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷362及答案解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 362及答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.给定程序中,函数 fun的功能是:求出形参 SS所指字符串数组中最长字符串的长度,将其余字符串右边用字符 “*”补齐,使其与最长的字符串等长。ss 所指字符串数组中共有 M个字符串,且串长 #include #define M 5 #define N 20 void fun (char (*ss) N ) int i,j,n len=0; len=strlen (ss i ) ; if (i=0) n=len; if (lenn) n=len; for

2、i=0;i_三、程序设计题(总题数:1,分数:2.00)3.请编写函数 fun,对长度为 7个字符的字符串,除首、尾字符外,将其余 5个字符按 ASCII码降序排列。例如,原来的字符串为:CEAedca,排序后输出为: CedcEAa。 注意:部分源程序在文件 PROG1C 中。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 #include #include #include void fun (char *s,int num) NONO() /*请在此函数内打开文件,输入测试数据,调用 fun函数,输出数据,关闭文件。 */ char

3、s10; FILE *rf, *wf ; int i = 0 ; rf= fopen(“indat“,“r“); wf fopen (“outdat“,“W“); while(in) n=len; for(i=0;i_正确答案:(正确答案:(1)i f(* p=) (2)* (p1)=toupper(* (p1);)解析:解析:函数的功能是将每个单词的最后一个字母改成大写。 (1)第一个错误标识下的 if语句应该是判断字符串中的字符是否是空格,根据“for(;*p;p+)”语句中 for循环条件中 p的定义应该为字符型指针变量,*p 是取 p所指存取单元的值,所以“if(p=)”应该改为“if

4、p=)”。 (2)题干中要求是将每个单词的最后一个字母改成大写,所以它的位置应该是挨着空格的前一个字符,应该是指针 p指向字符的前一个位置,“*p=toupper(*(pl)”是将改动的值赋给了 p所指的空格,所以应该改为“*(p1)=toupper(*(p1));”且语句未尾应有分号。三、程序设计题(总题数:1,分数:2.00)3.请编写函数 fun,对长度为 7个字符的字符串,除首、尾字符外,将其余 5个字符按 ASCII码降序排列。例如,原来的字符串为:CEAedca,排序后输出为: CedcEAa。 注意:部分源程序在文件 PROG1C 中。 请勿改动主函数 main和其他函数中的

5、任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 #include #include #include void fun (char *s,int num) NONO() /*请在此函数内打开文件,输入测试数据,调用 fun函数,输出数据,关闭文件。 */ char s10; FILE *rf, *wf ; int i = 0 ; rf= fopen(“indat“,“r“); wf fopen (“outdat“,“W“); while(i 10) fgets (s,10,rf); s7 = 0 ; fun (s,7); fprintf (wf, “s/rll“ s); i+ ; ) fclose (rf); fclose (wf); main() char s10; printf(“输入 7个字符的字符串:“); gets (s); fun (s,7); printf (“/ns“,s); NONO(); (分数:2.00)_正确答案:(正确答案:1 char t; 2 int ij; 3 for (i=1; i解析:解析:选择排序法中的降序排序,首先从数组中挑选一个最大的元素,把它和第一个元素交换,接着从剩下 的 num1个元素中再挑出一个最大的元素,把它和第二个 元素交换,不断重复以上过程,直到比较完最后两个元素。

展开阅读全文
相关资源
猜你喜欢
  • KS I ISO 22032-2007 Water quality-Determination of selected polybrominated diphenyl ethers in sediment and sewage sludge-Method using extraction and gas chromatography mass spectro.pdf KS I ISO 22032-2007 Water quality-Determination of selected polybrominated diphenyl ethers in sediment and sewage sludge-Method using extraction and gas chromatography mass spectro.pdf
  • KS I ISO 22478-2007 Water quality-Determination of certain explosives and related compounds-Method using high-performance liquid chromatography (HPLC) with UV detection《水质 某炸药及其相关化.pdf KS I ISO 22478-2007 Water quality-Determination of certain explosives and related compounds-Method using high-performance liquid chromatography (HPLC) with UV detection《水质 某炸药及其相关化.pdf
  • KS I ISO 22719-2009 Water quality-Determination of total alkalinity in sea water using high precision potentiometric titration《水质 用高精度电位滴定仪测定海水总碱度》.pdf KS I ISO 22719-2009 Water quality-Determination of total alkalinity in sea water using high precision potentiometric titration《水质 用高精度电位滴定仪测定海水总碱度》.pdf
  • KS I ISO 22743-2009 Water quality-Determination of sulfates-Method by continuous flow analysis(CFA)《水质 硫酸盐测定 连续流量分析法(CFA)》.pdf KS I ISO 22743-2009 Water quality-Determination of sulfates-Method by continuous flow analysis(CFA)《水质 硫酸盐测定 连续流量分析法(CFA)》.pdf
  • KS I ISO 22892-2007 Soil quality-Guidelines for the identification of target compounds by gas chromatography and mass spectrometry《土质 用气相色谱法和质谱法对靶子化合物识别的指南》.pdf KS I ISO 22892-2007 Soil quality-Guidelines for the identification of target compounds by gas chromatography and mass spectrometry《土质 用气相色谱法和质谱法对靶子化合物识别的指南》.pdf
  • KS I ISO 23611-1-2007 Soil quality-Sampling of soil invertebrates-Part 1:Hand-sorting and formalin extraction of earthworms《土质 土壤无脊椎动物的取样 第1部分 蚯蚓的手工拣取和福尔马林萃取》.pdf KS I ISO 23611-1-2007 Soil quality-Sampling of soil invertebrates-Part 1:Hand-sorting and formalin extraction of earthworms《土质 土壤无脊椎动物的取样 第1部分 蚯蚓的手工拣取和福尔马林萃取》.pdf
  • KS I ISO 23611-2-2007 Soil quality-Sampling of soil invertebrates-Part 2:Sampling and extraction of micro-arthropods(Collembola and Acarina)《土质 土壤无脊椎动物的抽样 第2部分 微型节肢动物的取样和萃取(弹尾目和蜱螨目.pdf KS I ISO 23611-2-2007 Soil quality-Sampling of soil invertebrates-Part 2:Sampling and extraction of micro-arthropods(Collembola and Acarina)《土质 土壤无脊椎动物的抽样 第2部分 微型节肢动物的取样和萃取(弹尾目和蜱螨目.pdf
  • KS I ISO 23631-2007 Water quality-Determination of dalapon trichloroacetic acid and selected haloacetic acids-Method using gas chromatography(GC-ECD and or GC-MS detection) after l 对.pdf KS I ISO 23631-2007 Water quality-Determination of dalapon trichloroacetic acid and selected haloacetic acids-Method using gas chromatography(GC-ECD and or GC-MS detection) after l 对.pdf
  • KS I ISO 23753-1-2006 Soil quality-Determination of dehydrogenase activity in soils- Part 1:Method using triphenyltetrazolium chloride(TTC)《土壤质量 土壤中脱氢酶活性的测定 第1部分 使用氯化三苯基四唑(TTC)的方法》.pdf KS I ISO 23753-1-2006 Soil quality-Determination of dehydrogenase activity in soils- Part 1:Method using triphenyltetrazolium chloride(TTC)《土壤质量 土壤中脱氢酶活性的测定 第1部分 使用氯化三苯基四唑(TTC)的方法》.pdf
  • 相关搜索

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

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