资源预览内容
第1页 / 共18页
第2页 / 共18页
第3页 / 共18页
第4页 / 共18页
第5页 / 共18页
第6页 / 共18页
第7页 / 共18页
第8页 / 共18页
第9页 / 共18页
第10页 / 共18页
亲,该文档总共18页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
c 语言程序设计模拟试题 A 答案专业 班级 学号 姓名 题号一二三四五六七八总分得分 一、单选题(15 分) 1、若有定义:int a=8, b=5, c; 执行语句 c = a/b+0.4 ;后,c 的值为( B ) 。A) 1.4 B) 1 C) 2.0 D) 22 、以下程序中,while 循环的次数是( B ) 。#include void main(void) int i = 0; while (ivoid main(void) int a = 0, i; for (i=1; ivoid main(void) int i = 0, j = 0, a = 6; if (+i0)|(+j0) a +; printf(“i=%d, j=%d, a=%dn”, i, j, a);A) i=0, j=0, a=6 B) i=1, j=1, a=7 C) i=1, j=0, a=7 D) i=0, j=1, a=76、执行以下程序后的输出结果是( D )#include void main(void) char a=”abc0abc”; printf(“%s”, a);A) abc0abc B) abc C) abc0 D) abc7、以下程序的输出结果是( C )#include void main(void) int a = 1, b = 2, c = 3; printf(“%d”, cba);A) 2 B) 1 C) 0 D) 38、执行以下程序后,a 的值为( D ) 。int *p, a = 10, b=1;p = a = *p + b;A) 12 B) 编译出错 C) 10 D) 119、以下正确的叙述是( C ) 。 A) 在 C 语言中,main 函数必须位于文件的开头 B) C 语言每行中只能写一条语句 C) C 语言本身没有输入、输出语句 D) 对一个 C 语言进行编译预处理时,可检查宏定义的语法错误10、以下各语句或语句组中,正确的操作是( C ) 。 A) char s5=“abcde“B) char *s; gets(s); C) char *s; s=“abcde“;D) char s5; scanf(“%s“, 11、设有以下说明语句,则下面的叙述中不正确的是( B ) 。 struct ex int x ; float y; char z ; example; A) struct 结构体类型的关键字 B) example 是结构体类型名 C) x,y,z 都是结构体成员名 D) struct ex 是结构体类型12、对以下程序段,while 循环执行的次数是( A ) 。 int k=0 while (k=1) k+; A) 无限次 B) 有语法错,不能执行 C) 一次也不执行 D) 执行 1 次13、若已定义:int a9,*p=a;并在以后的语句中未改变 p 的值,则不能表示 a1 地址的 表达式是( C ) 。 A) p+1 B) a+1 C) a+ D) +p14、函数调用:strcat(strcpy(str1,str2),str3)的功能是( C ) 。 A) 将串 str1 复制到串 str2 中后再连接到串 str3 之后 B) 将串 str1 连接到串 str2 之后再复制到串 str3 之后 C) 将串 str2 复制到串 str1 中后再将串 str3 连接到串 str1 之后 D) 将串 str2 连接到串 str1 之后再将串 str1 复制到串 str3 中15、在下列选项中,不正确的赋值语句是( D ) 。 A) +t; B) n1=(n2=(n3=0); C) k=i=j; D) a=b+c=1;二、程序填空(26 分) 1、求 1!+2!+3!+。 。 。+10!#include void main(void) float s = 0, t = 1; int n; for (n=1; n void main(void) unsigned long num, max, t;int count;count=max=0;scanf(“%ld“, do t= num%10 ;if(t=0) +count;elseif(max void main(void) int i, j; for(i=0; ivoid main(void) char *s, *s1 = “here is”, *s2 = “key”; s = s1; while (*s1!=0) s1+; while (*s1+=*s2+); s2 = s; while (*s2!=0) s2+; printf(“%dn”, s2-s); 10 2、#include void main(void) static int a = 1, 3, 5, 7;int *p3 = a+2, a+1, a;int *q = p;printf(“%dn”, *(p0+1) + *(q+2); 8 3、#include void main(void) int num,c;printf(“请输入一个整数:“);scanf(“%d“,do c=num%10; printf(“%d“,c); while(num/=10)0); printf(“n“); 35-53 4、#include #include fut(int *s, int p23) *s=p11; void main(void) int a23 = 1,3,5,7,9,11, *p; p = (int *) malloc(sizeof(int); fut(printf(“%dn“,*p); 9 四、编程(35 分) (1)sum=2+5+8+11+14-,输入正整数 n,求 sum 的前 n 项和。 (2)求 1100 间的素数(素数1,且除了 1 和自身外,不能被任何其它整数整除。 (3)使用指针数组对输入输入的 3 个整数序列(每个序列 5 个整数)进行排序,排序方法 不限。 (10) 有 15 个数存放在一个数组中,输入一个数,用折半查找法找出该数是数组中第几个 元素。若该数不在数组中,则打印出“No found”。c 语言程序设计模拟试题 B专业 班级 学号 姓名 题号一二三四五六七八总分得分 五、单选题(15 分) 1、以下程序的输出结果是( C ) 。#include void main(void) int a = 5, b = 4, c = 6, d;printf(“%dn”, d=ab?(ac?a: c): b);A) 5 B) 4 C) 6 D) 不确定2、以下程序的输出结果是( A ) 。void main(void) int a = 4, b = 5, c = 0, d;d = !a printf(“%dn”, d);A) 1 B) 0 C) 非 0 的数 D) 13、以下程序的输出结果是( A ) 。#include int f(void) static int i = 0;int s =1; s += i; i+; return (s);void main(void) int i, a = 0; for (i=0; ivoid main(void) int i = 010, j =10, a = 0x10; printf(“%d, %d, %dn”, i, j, a);A) 8, 10, 16 B) 8, 10, 10 C) 10, 10, 10 D) 10, 10, 166、以下程序的输出结果是( D ) 。#include void main(void) int a = 7; float x = 2.5,y = 4.7; printf(“%g”, x+a%3*(int)(x+y)%2/4);A) 0 B) 2.75 C) 2 D) 2.57、下列语句行中,哪些语句能正确进行字符串赋值操作( C ) 。A) char st45 B) char s5=A, B, C, D, E C) char *s; s = “ABCDE”; D) char *s; scanf(“%s”, s); 8、以下程序的输出结果是( D ) 。#include void main(void) char a = 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, *p = a+5; printf(“%d”, *-p);A) 非法 B) a4的地址 C) 3 D) 59、以下程序的运行结果是( C ) 。 #include void main(void) int a43= 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12;int *p4, j;for (j=0; j int compare(char *s1, char *s2) while(*s1s2+ ;return *s1*s2?1:-1 ; void main(void) printf(“%dn“, compare(“abCd“, “abc“); 2、函数 fun 的功能是:使字符串 str 按逆序存放。 void fun (char str) char m; int i, j; for (i=0, j=strlen(str); i void main( void) float x1000,sum=0.0,ave,a; int n=0,i; printf(“Enter mark:n“); scanf(“%f“,int x = 2;int x = 3;printf(“x= %dn”, x);printf(“x= %dn”, x);printf(“x= %dn”, x); x=3 x=2 x=1 2、#include void main(void) static char s = “china”, c;int i, j;for (i=0; i=1; j-) if (sj void f(int c) int a=0;static int b=0;a+;b+;printf(“%d: a=%d, b=%dn“, c, a, b); void main(void) int i;for (i=1; i struct stu int num; char name10; int age; ; void fun(struct stu *p) printf(“%sn“,(*p).name); void main(void) struct
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号