欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOC文档下载  

    中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc

    • 资源ID:4126057       资源大小:121KB        全文页数:11页
    • 资源格式: DOC        下载积分:8金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要8金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc

    2012春电大C语言程序设计模拟试题及解答一、选择题 1. 由C语言源程序文件编译而成的目标文件的缺省扩展名为( C )。 A. cpp B. exe C. obj D. C 2. C语言程序的基本模块为( D )。 A. 表达式 B. 标识符 C. 语句 D. 函数 3. 设x和y均为逻辑值,则x|y为假的条件是( C )。 A它们均为真 B.其中一个为真 C.它们均为假 D.其中一个为假 4. x>0 | y=5的相反表达式为( B )。A. x<=0 | y!=5 B. x<=0 && y!=5C. x>0 | y!=5 D. x>0 && y=5 5. 枚举类型中的每个枚举常量的值都是一个( A )。 A. 整数 B. 浮点数 C. 字符 D. 逻辑值6. 循环体至少被执行一次的语句为( C )循环语句。 Afor B.while C.do-while D.任一种 7. 循环语句“for(int i=0; i<n; i+) S;”中循环体S被执行的次数为( C )。 A. 1 B. n-1 C. n D. n+1 8. 在下面的while循环语句中,其循环体被执行的次数为( C )。 int i=0,s=0; while(s<20) i+; s+=i; A. 4 B. 5 C. 6 D. 79在下面的字符数组定义中,( D )语句有语法错误。 Achar a20=“abcdefg”; Bchar a=“x+y=55.”; C. char a15=1, 2; D. char a10=5;10. 若定义了函数 double *function(), 则返回值类型为( B )。 A. 实数型 B. 实数指针型 C. 函数指针型 D. 数组型 11. 若用数组名作为函数调用的实参,传递给形参的是( A )。 A. 数组的首地址 B. 数组中第一个元素的值 C. 数组中全部元素的值 D. 数组元素的个数12.预处理命令在程序中都是以( B )符号开头的。A.* B.# C.& D. 13. 假定a为一个整型数组名,则元素a4的地址比该数组的首地址大( C )个字节。 A. 4 B. 8 C. 16 D. 32 14. 下列给字符数组赋初值时,正确的是( A )。 A. char s1="abcdef" B. char s24="abcd" C. char s323="abc","xyz" D. char s44='a','x','s','t' 15. 变量已定义为char *s=Heoll world!;,要使变量指向所指向的同一个字符串,则应定义为(A)。 A. char *p=s; B. char *p=&s; C. char *p;p=*s; D. char *p; p=&s; 16. 要使p指向二维整型数组a1020,p应定义为( D )。 A. int *p=a; B. int *p=a; C. int *p20=a; D. int(*p)20=a; 17. 标准输入设备的文件流标识符是( A )。 A. stdin B. stdout C. stderr D. stdio 18. 若要以读/写操作方式打开一个二进制文件,当文件不存在时返回打开失败信息,则选用的打开方式字符串为( C )。 A. "r+" B. "ab+" C. "rb+" D. "wb+"二、填空题 1. 单行或多行注释的开始标记符为 /* 。2. C语言程序中所有预处理命令均以 # 字符开头。3. 使用#include命令可以包含一个头文件,也可以包含一个 程序 文件。 4. 用于从键盘上变为变量输入值得标准输入函数是 sanf() 。 5. 执行“printf("%s%s%d","wei","rong",18);”语句后得到的输出结果为weirong18。6. 十进制数25表示成符合C语言规则的八进制数为 031 。7执行“printf("%c",'A'+2);”语句后得到的输出结果为 C 。 8. 假定一个枚举类型的定义为“enum RAab,ac,ad,ae;”,则ac值为 1 。 9short类型的大小为 2 个字节。 10. double类型的大小为 8 个字节。 11. 十进制数3.26f的类型为 float 。 12. 执行“int=45,y=13;printf(“%d”,x/y);”语句序列后得到的输出结果为 3 。 13. 假定y=10,则表达式+y*3的值为 33 。 14. 表达式x=x+y表示成复合赋值表达式为 x+y=y 。 15. 关系表达式(x=0)的等价表达式为 (!x) 。 16. 假定不允许使用逻辑非操作符,则逻辑表达式x>3 && x<10的相反表达式为 x<=3 | x>=10 。 17若x=5,y=10,则x!=y的逻辑值为 1 。 18. 假定x=5,则执行“int a=(! X? 10:20);”语句后a的值为 20 。19. 在if语句中,每个else关键字与它前面同层次并且最接近的 if 关键字相配套。 20. 若while循环的“头”为“while(i+<=10)”,并且i的初值为0,同时在循环体中不会修改i的值,则循环体将被重复执行 11 次后正常结束。 21. 当在程序中执行到 contioue 语句时,将结束所在循环语句中循环体的一次执行。 22. 假定二维数组的定义为“char a35;”,则该数组所含元素的个数为 15 。 23假定二维数组的定义为“char aMN;”,则该数组所占存储空间的字节数为 M*N 。 24. 执行“typedef int ABC10;”语句把ABC定义为具有10个整形元素的 数组 类型。 25. 存储字符串“a”需要占用存储器的 2 个字节空间。 26. 字符串“axy=4n”的长度为 8 。 27. strlen函数用于计算一个字符串的 长度 。 28. strcat函数用于把一个字符串 连接 到另一个字符串之后的存储空间中。 29函数中的形参变量的初值由调用该函数时对应的 实参 值决定。 30. 对于无返回值函数,定义函数时要用保留字 void 修饰函数类型。 31. 程序的编译是以 程序文件 为单位进行的。 32. 假定p所指向对象的值为25,p+1所指对象的值为46,则执行“(*p)+;”语句后,p所指向对象的值为 26 。 33. 假定a是一个一维数组,则ai的指针访问方式为 *(a+i) 。 34. 假定p是一个指向整数对象的指针,则用 *p 表示该整数对象。 35. 执行int *p=malloc(sizeof(int)操作得到的一个动态分配的整型对象为 *p 。 36. 假定一个结构类型的定义为“struct Cdouble* a4;int n;”,则该类型的大小为 20 个字节。 37. 假定要动态分配一个类型为struct Worker的具有n个元素的数组,并由r指向这个动态数组,则使用的语句表达式为 struct Worker* r =malloc(n*sizeof(struct Worker)。 38. 与结构成员访问表达式p->name等价的表达式是 (*p).name 。三、写出下列每个程序运行后的输出结果 1. #include<stdio.h> void main() int i, s=0; for(i=1;i+) if(s>50) break; if(i%2=0) s+=i; printf("i,s=%d, %dn",i,s); 结果:i,s=15,56 2. #include<stdio.h> void main() 结果* char ch='*' int i, n=5; while(1) for(i=0;i<n;i+) printf("%c",ch); printf("n"); if(-n=0) break; 3. #include<stdio.h>const int N=5;void main()结果 1 1 1 2 2 2 3 6 9 4 24 33 int i,p=1,s=0; for(i=1;i<N;i+) p=p*i; s=s+p; printf("%5d%5d",i,p); printf("%5dn",s); 4. #include<stdio.h> void main() int x=24,y=88; int i=2,p=1; do while(x%i=0 && y%i=0) p*=i; x/=i; y/=i; i+; while(x>=i && y>=i); printf("%dn",p*x*y); 结果:p*x*y=8*3*11=264 5. #include<stdio.h> void main() int a9=36,25,48,24,55,40,18,66,20; int i, b1, b2; a0<=a1? (b1=a0, b2=a1):(b1=a1,b2=a0); for(i=2; i<9; i+) if(ai<b1) b2=b1; b1=ai; else if(ai<b2) b2=ai; printf("%d %dn",b1,b2); 结果:18 20 6. #include<stdio.h> void main() int a12=76,63,54,62,40,75,80,92,77,84,44,73; int b4=60,70,90,101; int c4=0; int i,j; for(i=0;i<12;i+) j=0; while(ai>=bj) j+; cj+; for(i=0;i<4;i+) printf("%d",ci); printf("n"); 结果:3 2 6 17. #include<stdio.h> void main() int a=10, b=20;结果 10 20 40 35 40 20 printf("%d %dn",a,b); int b=a+25; a*=4; printf("%d %dn",a,b); printf("%d %dn",a,b); 8. #include<stdio.h> void SelectSort(int a, int n) int i,j,k,x; for(i=1;i<n;i+) /进行n-1次选择和交换 k=i-1; for(j=i;j<n;j+) if(aj<ak) k=j; x=ai-1; ai-1=ak; ak=x; void main() int i; int a6=20,15,32,47,36,28; SelectSort(a,6); for(i=0; i<6; i+) printf("%d ",ai); printf("n"); 结果:15 20 28 32 36 47 9#include<stdio.h> void main() int a8=4,8,12,16,20,24,28,32; int *p=a; do printf("%d",*p); p+=2; while(p<a+8); printf("n"); 结果:4 12 20 28 10. #include<stdio.h> void LE(int* a, int* b) int x=*a; *a=*b; *b=x; 结果15 26 26 15 void main() int x=15, y=26; printf("%d %dn",x,y); LE(&x,&y); printf("%d %dn",x,y); 11. #include<stdio.h> #include<string.h> struct Worker char name15; /姓名 int age; /年龄 float pay; /工资 ; int Equal(struct Worker* r1, struct Worker* r2) if(strcmp(r1->name, r2->name)=0) return 1; else return 0; void main() struct Worker a4="abc",25,420,"defa",58,638, "ghin",49,560,"jklt",36,375; struct Worker x="defa" int i; for(i=0; i<4; i+) if(Equal(a+i,&x) break; if(i>=4) printf("没有查找所需要的记录!n"); else printf("%s %d %6.2fn",ai.name,ai.age,ai.pay); 结果:defa 58 638.00四、写出下列每个函数的功能 1. int SE(int n) /n为大于等于1的整数 int x,s=0; printf("输入%d个整数: ",n); scanf("%d",&x); if(n=1) return x; s=x; while(-n) scanf("%d",&x); s+=x; return s; 函数功能:求出键盘上输入的n个整数之和并返回。2. float FH() float x,y=0,n=0;scanf("%f",%x);while(x! =-1.0) n+; y+=x;scanf("%f",%x);if(n-0) return y; else return y/n; 函数功能:求出从键盘上输出的一批常数的平均值,以-1.0作为结束输入的标志。 3. #include<stdio.h> void WA(int a, int n) int i,k,j,x; for(i=0;i<n-1;i+) k=i; for(j=i+1;j<n;j+) if(aj>ak) k=j; x=ai; ai=ak; ak=x; 函数功能:采用选择排序的方法对数组a中的n个整数按照从大到小的次序重新排列。 4. #include<stdio.h> int* LJ(int a, int n) int i,k=0; for(i=1;i<n;i+) if(ai>ak) k=i; return &ak; 函数功能:求出数组a中n个元素的最大值元素,返回该元素的地址。 5. void QC(struct StrNode* f) while(f) printf("%sn",f->name);f=f->next; 假定结构类型StrNode的定义如下: stuct StrNode char name15; /字符串域 struct StrNode *next; /指针域 ; 函数功能:遍历f单链表,即从头结点开始依次输出f单链表中每个结点的值。待添加的隐藏文字内容3 6. int Output(struct IntNode *f) int sum=0; if(!f) return -9999; /用返回特定值-9999表示空表 while(f) sum+=f->data; f=f->next; return sum; 假定struct IntNode的类型定义为: struct IntNode int data; /结点值域 struct IntNode* next; /结点指针域 ; 函数功能:对于以表头指针为f的链表,求出并返回所有结点中data域的值之和。 7. int wr4(FILE* fptr) char ch; int c=0; fseek(fptr,0,SEEK_SET); while(1) ch=fgetc(fptr); if(ch!=EOF) c+; else break; return c; 函数功能:求出一个以fptr为文件流的所对应文件的长度,即所存字符的个数。五、根据下列每个题目要求编写程序1. 编写一个函数fun(),首先从键盘上输入一个4行4列的一个实数矩阵到一个二维数组a44中,接着求出主对角线上元素之和,最后返回求和结果。 #include<stdio.h> double fun() double a44; double s=0; int i,j; printf("输入一个4*4的数值矩阵:n"); for(i=0;i<4;i+) for(j=0;j<4;j+) scanf("%lf",&aij); for(i=0;i<4;i+) s+=aii;i return s; void main() printf("主对角线上元素之和是%lfn",fun(); 2. 编写一个主函数,计算1+3+32+.+310的值并输出,假定分别用i,p,s作为循环变量、累乘变量和累加变量的标识符。#include<stdio.h> void main() int i; /用i作为循环变量 int p=1; /用p作为累乘变量 int s=1; /用s作为累加循环变量 for(i=1;i<=10;i+) p*=3; s+=p; printf("%dn",s); 3. 编写一个主函数,已知6a40,15b30,求出满足不定方程2a+5b=120的全部整数组解。如(13,20)就是其中的一组解。#include<stdio.h> void main() int a,b; for(a=6;a<=40; a+) for(b=15;b<=30;b+) if(2*a+5*b=126) printf("(%d, %d)n",a,b); "If we don't do that it will go on and go on. We have to stop it; we need the courage to do it."His comments came hours after Fifa vice-president Jeffrey Webb - also in London for the FA's celebrations - said he wanted to meet Ivory Coast international Toure to discuss his complaint.CSKA general director Roman Babaev says the matter has been "exaggerated" by the Ivorian and the British media.Blatter, 77, said: "It has been decided by the Fifa congress that it is a nonsense for racism to be dealt with with fines. You can always find money from somebody to pay them."It is a nonsense to have matches played without spectators because it is against the spirit of football and against the visiting team. It is all nonsense."We can do something better to fight racism and discrimination."This is one of the villains we have today in our game. But it is only with harsh sanctions that racism and discrimination can be washed out of football."The (lack of) air up there Watch mCayman Islands-based Webb, the head of Fifa's anti-racism taskforce, is in London for the Football Association's 150th anniversary celebrations and will attend City's Premier League match at Chelsea on Sunday."I am going to be at the match tomorrow and I have asked to meet Yaya Toure," he told BBC Sport."For me it's about how he felt and I would like to speak to him first to find out what his experience was."Uefa has opened disciplinary proceedings against CSKA for the "racist behaviour of their fans" during City's 2-1 win.Michel Platini, president of European football's governing body, has also ordered an immediate investigation into the referee's actions.CSKA said they were "surprised and disappointed" by Toure's complaint. In a statement the Russian side added: "We found no racist insults from fans of CSKA."Baumgartner the disappointing news: Mission aborted.The supersonic descent could happen as early as Sunda.The weather plays an important role in this mission. Starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. It will climb higher than the tip of Mount Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.The balloon will slowly drift to the edge of space at 120,000 feet ( Then, I would assume, he will slowly step out onto something resembling an Olympic diving platform.Below, the Earth becomes the concrete bottom of a swimming pool that he wants to land on, but not too hard. Still, he'll be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. It will be like he is diving into the shallow end.Skydiver preps for the big jumpWhen he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds. Like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to Earth. But this will not be enough to stop him completely.If he goes too fast or spins out of control, he has a stabilization parachute that can be deployed to slow him down. His team hopes it's not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 meters).In order to deploy this chute successfully, he will have to slow to 172 mph (277 kph). He will have a reserve parachute that will open automatically if he loses consciousness at mach speeds.Even if ever

    注意事项

    本文(中央电大C语言程序设计模拟试题及解答(亲测)小抄参考.doc)为本站会员(文库蛋蛋多)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开