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

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

1、国家二级 C语言机试(操作题)模拟试卷 185及答案与解析 一、程序填空题 1 给定程序中,函数 fun的功能是:有 NxN矩阵,根据给定的 m(m #define N 4 void fun(int (*t)N, int m) int i, j; *found* for(i=0; i=0 ; j-) *found* tij+_2_=tij; *found* for(j=0; j *found* void fun(long s, long t) long s1=10; *t=s 10; while(s0) s=s 100; *t=s 10 * s1+*t; *found* s1=s1*100;

2、main() long s, t ; printf(“ nPlease enter s: “); scanf(“ ld“, s), fun(s, t); printf(“The result is: ld n“, t); 三、程序设计题 3 请编写函数 fun,它的功能是:求出 ss所指字符串中指定字符的个数,并返回此值。 例如,若输入字符串: 123412132,输入字符为: 1,则输出: 3。 注意:部分源程序在文件 PROGl C中。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 #include #include #define M

3、81 int fun(char*ss, char c) main() char aM, ch; void NONO(); printf(“ nPlease enter a string: “); gets(a); printf(“ nPlease enter a char: “); ch=getchar(); printf(“ nThe number of the char is: d n“, fun(a, ch); NONO(); void NONO() *本函数用于打开文件 ,输入测试数据,调用 fun函数,输出数据,关闭文件。* int i; FILE*rf, *wf; char aM,

4、 bM, ch; rf=fopen(“in dat“, “r“); wf=fopen(“out dat“, “w“); for(i=0 ; i=0; i一 )”是进行行元素中的值右移 m个位置,即把 tij元素放置在 tij+m上,因此第 二空应为 “m”。 第三空:循环 “for(j=0; j_3_; j+)”是对空出来的位置补 0,每行元素的前m位数据已经移动到后面,每行空处 m个元素,因此第三空为 “m”。 二、程序修改题 2 【正确答案】 (1)void fun (long s, long *t) (2)sl=sl*10; 【试题解析】 (1)根据 “*t=s 10”判断, t应该是个

5、指针变量,所以 “void fun(long s, long t)”语句中的 t只需改为 “voidfun(long s, long*t)”。 (2)分析函数内的循环过程可知 s1的用途是每次将 *t扩大,记录每次得到的奇数位的数字的权值, sl的权值每次增加 1位,因此第二个标识下应该是“sl=sl*10; ”。 三、程序设计题 3 【正确答案】 int cnt=0; char*p=ss; while(*p) if(*p=c)cnt+; p+; return cnt; 【试题解析】 如果不是串尾就进入 while循环,在循环过程中利用 if条件表达式判断当前字符是否为指定的字符,如果符合条件,那么对统计计数变量进行加 1操 作。

展开阅读全文
相关资源
猜你喜欢
  • BS PD CEN TR 17024-2017 Natural stones Guidance for use of natural stones《天然石料 天然石料使用指南》.pdf BS PD CEN TR 17024-2017 Natural stones Guidance for use of natural stones《天然石料 天然石料使用指南》.pdf
  • BS PD CEN TR 17039-2017 Railway applications Technical Report about the revision of EN 14363《轨道交通 EN 14363修改技术报告》.pdf BS PD CEN TR 17039-2017 Railway applications Technical Report about the revision of EN 14363《轨道交通 EN 14363修改技术报告》.pdf
  • BS PD CEN TR 17040-2017 Fertilizers and liming materials Sampling of static heaps Technical report on experimental sampling trials performed under mandate M 454《肥料和石灰质材料 静.pdf BS PD CEN TR 17040-2017 Fertilizers and liming materials Sampling of static heaps Technical report on experimental sampling trials performed under mandate M 454《肥料和石灰质材料 静.pdf
  • BS PD CEN TR 17055-2017 Workplace exposure Measurement of chemical agents complying with the requirements given in EN 482 and either one of EN 838 EN 1076 EN 13205 EN 1389.pdf BS PD CEN TR 17055-2017 Workplace exposure Measurement of chemical agents complying with the requirements given in EN 482 and either one of EN 838 EN 1076 EN 13205 EN 1389.pdf
  • BS PD CEN TR 17063-2017 Foods of plant origin Multimethod for the determination of pesticide residues using GC- or LC-based analysis following acetonitrile extraction part.pdf BS PD CEN TR 17063-2017 Foods of plant origin Multimethod for the determination of pesticide residues using GC- or LC-based analysis following acetonitrile extraction part.pdf
  • BS PD CEN TR 17068-2017 Sealants for non-structural use in joints in buildings and pedestrian walkways Guidance for CE marking and Declaration of Performance (DoP)《建筑物和人行道.pdf BS PD CEN TR 17068-2017 Sealants for non-structural use in joints in buildings and pedestrian walkways Guidance for CE marking and Declaration of Performance (DoP)《建筑物和人行道.pdf
  • BS PD CEN TR 17078-2017 Stationary source emissions Guidance on the application of EN ISO 16911-1《固定源排放 EN ISO 16911-1应用指南》.pdf BS PD CEN TR 17078-2017 Stationary source emissions Guidance on the application of EN ISO 16911-1《固定源排放 EN ISO 16911-1应用指南》.pdf
  • BS PD CEN TR 17144-2017 Resistance of metallic materials to liquid biogenic and alternative fuels and their blends《金属材料对液体生物燃料和替代燃料及其混合物的耐受性》.pdf BS PD CEN TR 17144-2017 Resistance of metallic materials to liquid biogenic and alternative fuels and their blends《金属材料对液体生物燃料和替代燃料及其混合物的耐受性》.pdf
  • BS PD CEN TR 196-4-2007 Methods of testing ncement — nPart 4 Quantitative determination of nconstituents《水泥的测试方法 第4部分 组分的定量测定》.pdf BS PD CEN TR 196-4-2007 Methods of testing ncement — nPart 4 Quantitative determination of nconstituents《水泥的测试方法 第4部分 组分的定量测定》.pdf
  • 相关搜索

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

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