[计算机类试卷]国家二级C语言机试(操作题)模拟试卷341(无答案).doc

上传人:figureissue185 文档编号:846896 上传时间:2019-02-21 格式:DOC 页数:4 大小:29KB
下载 相关 举报
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷341(无答案).doc_第1页
第1页 / 共4页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷341(无答案).doc_第2页
第2页 / 共4页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷341(无答案).doc_第3页
第3页 / 共4页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷341(无答案).doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C 语言机试(操作题)模拟试卷 341(无答案)一、程序填空题1 给定程序中,函数 fun 的功能是用函数指针指向要调用的函数,并进行调用。规定在 2 处使 fa 指向函数 f1,在 3 处使 fb 指向函数 f2。当调用正确时,程序输出:x1=5000000 ,x2=3 000000,x1*x1+x1*x2=40 000000请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。注意:源程序存放在考生文件夹下的 BLANK1C 中。不得增行或删行,也不得更改程序的结构!#include double fl (double x) return x*x; double

2、f2 (double x, double y) return x*y; double fun(double a,double b)double r1,r2;f=_2_; /* point fountion f1 */f= _3_ ; /* point fountion f2 *1return r1 + r2;main () double x1=5,x2=3,r;r =fun (x1, x2);printf(“nx1=f,x2=f,x1*x1+x1*x2=fn“,x1, x2, r) ;二、程序修改题2 给定程序 MODI1C 是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数 fun

3、 的功能是将单向链表结点(不包括头结点)数据域为偶数的值累加起来,并且作为函数值返回。请改正函数 fun 中指定部位的错误,使它能得出正确的结果。注意:不要改动mam 函数,不得增行或删行,也不得更改程序的结构!#include #include typedef struct aa int data; struct aa *next; NODE;int fun (NODE *h) int sum=0 ;NODE *p;p=h;while (p) if (pdatao02=0)sum +=pdata;p=hnext;return sum;NODE *creatlink(int n)NODE *h

4、,*p,*s ;int i;h=p= (NODE *) malloc ( sizeof (NODE) ; s= (NODE *) malloc (sizeof (NODE) ;sdata=rand () 16; snext=pnext;pnext=s ;p=pnext;pnext=NULL;return h;outlink(NODE *h,FILE *pf)NODE *p;p = hnext;fprintf(pf , “nnTHE LIST :nnHEAD “);while (p) fprintf (pf ,“d “,pdata) ;p=pnext; fprintf (pf,“n“) ;out

5、result (int s FILE *pf) fprintf(pf, “nThe sum of evennumbers : dn“ ,s); main ( )NODE *head; int even;head=creatlink (12) ;headdata=9000;outlink (head , stdout) ;even=fun (head) ;printf(“nThe result :n“) ;outresult (even, stdout) ;三、程序设计题3 请编写函数 fun,函数的功能是:判断字符串是否为回文?若是,函数返回 1,主函数中输出:YES;否则返回 0,主函数中输

6、出 NO。回文是指顺读和倒读都一样的字符串。例如,字符串 LEVEL 是回文,而字符串 123312 就不是回文。注意:部分源程序在文件 PROG1C 中。请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入你编写的若干语句。#include #include #define N 80int fun (char *str)main()char sN ;void NONO ();printf (“Enter a string:“),gets (s);printf(“nn“); puts (s);if (fun (s) printf (“YESn“);else printf( “NOn“);NONO();)void NONO ()/*请在此函数内打开文件,输入测试数据,调用 fun 函数,输出数据,关闭文件。*/FILE *rf,*wf ;int i ; char sN ;rf=fopen( “indat“ ,“r“);wf = fopen (“outdat“, “w“);for(i=0 ; i10 ; i+) fscanf (rf, “ s“,s), if( fun (s) fprintf (wf, “sYESn“,s);else fprintf(wf,“ s NOn“,s);fclose (rf); fclose (wf);

展开阅读全文
相关资源
猜你喜欢
  • BS EN 10250-2-2000 Open steel die forgings for general engineering purposes Non-alloy quality and special steels《一般工程用敞口钢模锻件 非合金质量特种钢》.pdf BS EN 10250-2-2000 Open steel die forgings for general engineering purposes Non-alloy quality and special steels《一般工程用敞口钢模锻件 非合金质量特种钢》.pdf
  • BS EN 10250-3-2000 Open steel die forgings for general engineering purposes Alloy special steels《一般工程用敞口钢模锻件 合金特种钢》.pdf BS EN 10250-3-2000 Open steel die forgings for general engineering purposes Alloy special steels《一般工程用敞口钢模锻件 合金特种钢》.pdf
  • BS EN 10250-4-2000 Open steel die forgings for general engineering purposes Stainless steels《一般工程用敞口钢模锻件 不锈钢》.pdf BS EN 10250-4-2000 Open steel die forgings for general engineering purposes Stainless steels《一般工程用敞口钢模锻件 不锈钢》.pdf
  • BS EN 10251-2015 Magnetic materials Methods of determination of the geometrical characteristics of electrical steel sheet and strip《磁性材料 电工钢片和钢带几何特性值测定方法》.pdf BS EN 10251-2015 Magnetic materials Methods of determination of the geometrical characteristics of electrical steel sheet and strip《磁性材料 电工钢片和钢带几何特性值测定方法》.pdf
  • BS EN 10252-1997 Magnetic materials - Methods of measurement of magnetic properties of magnetic steel sheet and strip at medium frequencies《磁性材料 以中频测量磁钢薄板材和带材磁性能的方法》.pdf BS EN 10252-1997 Magnetic materials - Methods of measurement of magnetic properties of magnetic steel sheet and strip at medium frequencies《磁性材料 以中频测量磁钢薄板材和带材磁性能的方法》.pdf
  • BS EN 10253-1-1999 Butt-welding pipe fittings - Wrought carbon steel for general use and without specific inspection requirements《对接焊管道接头 通用和无特殊检验要求的锻制碳钢》.pdf BS EN 10253-1-1999 Butt-welding pipe fittings - Wrought carbon steel for general use and without specific inspection requirements《对接焊管道接头 通用和无特殊检验要求的锻制碳钢》.pdf
  • BS EN 10253-2-2007 Butt-welding pipe fittings - Non alloy and ferritic alloy steels with specific inspection requirements《对接焊管道接头 带专门检验要求的非合金和铁素体合金钢》.pdf BS EN 10253-2-2007 Butt-welding pipe fittings - Non alloy and ferritic alloy steels with specific inspection requirements《对接焊管道接头 带专门检验要求的非合金和铁素体合金钢》.pdf
  • BS EN 10253-3-2008 Butt-welding pipe fittings - Part 3 Wrought austenitic and naustenitic-ferritic (duplex) stainless steels without specific ninspection requirements《对焊管接头 无特殊检验要求.pdf BS EN 10253-3-2008 Butt-welding pipe fittings - Part 3 Wrought austenitic and naustenitic-ferritic (duplex) stainless steels without specific ninspection requirements《对焊管接头 无特殊检验要求.pdf
  • BS EN 10254-1999 Steel closed die forgings General technical delivery conditions《钢闭合模锻件 一般技术交付条件》.pdf BS EN 10254-1999 Steel closed die forgings General technical delivery conditions《钢闭合模锻件 一般技术交付条件》.pdf
  • 相关搜索

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

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