2023年江苏省盐城市全国计算机等级考试C语言程序设计预测试题(含答案).docx





《2023年江苏省盐城市全国计算机等级考试C语言程序设计预测试题(含答案).docx》由会员分享,可在线阅读,更多相关《2023年江苏省盐城市全国计算机等级考试C语言程序设计预测试题(含答案).docx(40页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、2023年江苏省盐城市全国计算机等级考试C语言程序设计预测试题(含答案)学校:班级:姓名:考号:一、2.填空题(10题)1 .下面程序的输出结果是Omain() static char a=nlanguagen, b=nprogramn;char ptrl=a, *ptr2=b ;int kfor(k=0 ; k 7 ; k+)if( *(ptrl+k)=* (ptr2+k) printf(u%cn, *(ptrl+k) ; 2 .以下程序运行后的输出结果是【】。main() inti,j,a 3= 1,2,34,5,6,7,8,9);for(i=0;i 3;i+)for(j=i+l;j 3;
2、j+) aj i=0;for(i=0;i 3;i+) for(j=0;j 3;j+) printf(%d n,aij);printf(nnM);3 .设函数findbig已定义为求3个数中的最大值。以下程序将利用函数 25.n个人的成绩存放在score数组中,请编写函数proc (),它的功能是 将低于平均分的人数作为函数值返回,将低于平均分的分数放在down 所指的数组中。例如,当score数组中的数据为99, 80, 40, 56, 59, 84, 60, 76, 100时,函数返回的人数应该是4, down中的数据应为 40565960o注意:部分源程序给出如下。请勿改动main ()函
3、数和其 他函数中的任何内容,仅在函数proc ()的花括号中填入所编写的若干 语句。试题程序: g ineiudr V tdlih 9 inriiMie coaio.S include LntdKk S include Vzraig, tngid )ial It n down9ji mt 9rt *07gxXkkhv 9 dowvi)pnntf( *ndown to th* average tcorv .re, pritttf(eSd edownfiji prmtF(* *)i26.请编写一个函数void proc (int m, int k, int xxE3),该函数的功能是: 将大于整数
4、m且紧靠m的k个素数存入所指的数组中。例如,若输入 206,则应输出232931 3741 43。注意:部分源程序给出如下。请勿 改动main ()函数和其他函数中的任何内容,仅在函数proc ()的花括号中填入所编写的若干语句。试题程序:s include V tdbh. b$ include Vcomo, h3 include Vstdio. hvoed proci mt m. ml k mt MXt Pvoed )厮 mu 10001bsjrMefii iproc n rr) Cor(m0Oimnim A ,pttmf( *%1 prtaid*fi .)!27 .有N个学生,每个学生的信
5、息包括学号、性别、姓名、四门课的成 绩,从键盘上输入N个学生的信息,要求输出总平均成绩最高的学生信 息,包括学号、性别、姓名和平均成绩。28 .请编写函数void proc(int x, intpp, int*n),它的功能是:求出能 整除x且不是偶数、不为1的各整数,并按从大到小的顺序放在PP所 指的数组中,这些除数的个数通过形参n返回。例如,若x的值为30,则有3个数符合要求,它们是15, 5, 3o 注意:部分源程序给出如下。请勿改动main。函数和其他函数中的任何内容,仅在函数proc()的花括 号中填入所编写的若干语句。试题程序: include o. h incItMir Vzdi
6、o. h8 rncludc Mid pnc( mt fit p| J mt n) raid main ()ml rr:IOOO. n i ywtem( aCLS) $ priBtft *nPlcee rater afi ititegrr number As *) 4 ( proc-0 i i)pnatf (* Md * rr(i)i prifitf (、 ) i29.请编写一个函数proc (),它的功能是:将str所指字符串中所有下标 为奇数位置的字母转换为大写(若该位置上不是字母,则不转换)。例 如,若输入abcdel23,则应输出aBcDel23。注意:部分源程序给出如 下。请勿改动ma
7、in ()函数和其他函数中的任何内容,仅在函数proc0的花括号中填入所编写的若干语句。试题程序: tnclyclt9 iviclu(ir comk b)0 inclwftt V Mdlo. include V HHAg. *oid pFori*fiP1raw ffttvr Mnag wit Im10 cluirarlersMie)i.rtMtOi*rfiAlier HiegMf the *tmga Keet)epraH tt) praf H include 9 mclude inng. k raid prorchar Mr. char ()(char str 100 H1001 ,nEnLC
8、LSIprmtfC *nPlra9e rater *1 ring St .八*c川(.pcoc 0rOi pc miuli tsi %四、2.程序修改题(10题)31.下列给定程序中,函数fun()的功能是:根据输入的3个边长(整型 值),判断能否构成三角形:若能构成等边三角形,则返回3,若是等腰 三角形,则返回2,若能构成三角形则返回1,若不能,则返回0。 请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序:#include int fun(int a, int b, int c) if (a+b c&b+c a&a+c b
9、) if (a=二b&b二二c)/7,7,7,7, 7,7,7,。1 7,7,7,7,7,7,7,7,7,7,7,/不不不小不不小不小个不不不tci不小小不不不不小不不不小小不/return 1;else if(a=b| b=c|a=c)return 2;/1 7,kL*/不不个不不不不个个不不不小Tei个不不不不小个不不不个个不不/else return 3;else return 0;)main () int a,b, c, shape;printf(nnlnput a,b,c: n);scanf(n%d%d%d &a, &b, &c);printf (na=%d, b=%d, c=%dn
10、,a,b,c);shape=fun (a,b, c);printf (nnnThe shape : %dn, shape); )32.给定程序MOD11 . C中函数fun的功能是:输出M行M列整数方阵,然后求两条对角线上元素之和,返回此和数。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!include #define M 53456789/founder ,/int fun(int n, int xx) int i, j 9 sumO;printf(MnThe %d x %d matrix:nHrM, M);for(i - 0;
11、i M; i+) for(j 0; j M; j+)10111213141516 !)printf(w%f , xx(ij); printf(n);)for(1 - 0 ; i n ; i+)sum xxii*xxi(n-i-1; return(sum);181920 int aaM(4,3,2,1,0,6,7,8,9,0,(9,8,7,6,5),3,4,5,6,7;printf (wnThe sum of all elements on 2 diagnals is %d.fun(Mr aa);33.下列给定程序中,函数fun()的作用是,将字符串tt中的大写字母都 改为对应的小写字母,其他字
12、符不变。例如,若输入”Ab, cD,则输出 ab,cd0请改正函数fun()中的错误,使它能得出正确的结果。注童:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序:#include #include #include char *fun (char tt) int i;for(i=0; tti; i+)/vt# 4!|/不不不不不不不不不不不下不下tci in。不不不、不不不不不不不不不不/if(,A =tti|(tti=y)tti+=32; return(tt);)main()inti;char tt81;clrscr();printf(nnPlease enter a
13、 string:n);gets(tt);printf(nnThe result string is : n %sn, fun(tt);34.下列给定程序中,函数fun()的功能是:从N个字符串中找出最长的那个中,并将其地址作为函数值返回。各字符串在主函数中输入,并放 入一个字符串数组中。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include #include #define N 5#define M 81/I/不可不不不不不不不不不不可ci inc不不不不不可不不不不可不不不/fun(char (*sq) N)in
14、t i; char *sp;sp=sqO;fori=0;i N;i+) if(strlen(sp) strlen(sqi)sp=sqi;/kL#vl* vl*1kL*/不不不不不不不不不不不不不tciind不不不不不不不不不不不不不不/return sq;)main ()char strNM, longest; int i; printf(nEnter %d lines:n N);for(i=0;i N;i+) gets(stri);printf(nThe %d string :n ,N);for(i=0;i N;i+) puts(stri);longest=fun(str);printf(n
15、nThe longest string :n );puts(longest);35 .下列给定程序中函数fun()的功能是:从低位开始取出长整型变量s中偶数位上的数,依次构成一个新数放在t中。例如,当s中的数为7654321时,t中的数为642。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include #include /kA/不不不不不不不不不不不不不tci小小不不不不不不不不不小不不/void fun(long sjong t) long sl=10;s/=10;*t=s%10;/vtkJ kJ vf 1 /*1
16、 vt k!vl vl 1# vt# vl kT k1* k|/不不不不不不不不不不、下不丁 ciinri不不“,、(、下平不不少不不不不不/while(s 0) s=s/100;*t=s%10*sl+*t;sl=sl*10;)main() long s, t;clrscr();printf(nnPlease enter s: ); scanf (“ld”,&s);fun(s,&t);printf(nThe result is: %ldn tt);36 .下列给定程序中,函数fun()的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。请改正函数fun()中的错误,使它能
17、得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:#include #include void fun(char *s) int i,j;for(i = 0j = 0;si!=!0,; i+) if(si = O&si 1kL*kL*k1* /不不不不不不不不不不不不不Tei me不不不不不不不不不不不不不不/sj=si;/kl*/不不不不不不不不不不小不不Tei inc不不不不不不不不个不不不个个/sj = nO-指针调用findbig函数。请填空。main() int findbig(int,int,int);int (*f) () ,x,y, z
18、,big;f= : scanf(”d%d%d&x,&y,&z:big=(*f)(x,y,Z);printf(nbig=%dnbig); )4.设有下列程序:#include #include main() int i ;char s 10, t10;gets(t);for(i=0 ; i2 ; i+) gets(s);if(strcmp(t, s) 0)strcpy(t, s);)printf(%sn, t); )程序运行后,从键盘上输入(代表回车符):DEF BADEF QTHRG ,则程序的输出结果是O5.设有chara,b;,若要通过a&b运算屏蔽掉a中的其他位,只保留第2main()c
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2023 江苏省 盐城市 全国 计算机等级考试 语言程序设计 预测 试题 答案

限制150内