通过海量题库、编程比赛和实时排名,系统化提升您的编程能力。
第1题
以下叙述中正确的是( )。
在C语言中,预处理命令行都以“#”开头
预处理命令行必须位于C源程序的起始位置
#include<stdio.h>必须放在C程序的开头
C语言的预处理不能实现宏定义和条件编译的功能
第2题
以下关于编译预处理的叙述中错误的是( )。
预处理命令行必须位于源程序的开始
源程序中凡是以#开始的控制行都是预处理命令行
一行上只能有一条有效的预处理命令
预处理命令是在程序正式编译之前被处理的
第3题
以下关于宏的叙述中正确的是( )。
宏名必须用大写字母表示
宏定义必须位于源程序中所有语句之间
宏替换没有数据类型限制
宏调用比函数调用耗费时间
第4题
以下关于宏的叙述错误的是( )。
宏替换不具有计算功能
宏是一种预处理指令
宏名必须用大写字母构成
宏替换不占用运行时间
第5题
以下叙述中错误的是( )。
在程序中凡是以“#”开始的语句行都是预处理命令行
预处理命令行的最后不能以分号表示结束
#define MAX是合法的宏定义命令行
C程序对预处理命令行的处理是在程序执行的过程中进行的
第6题
若程序中有宏定义行:#define N 100则以下叙述中正确的是()。
宏定义行中定义了标识符N的值为整数100
上述宏定义行实现将100赋给标示符N
在运行时用100替换标识符N
在编译程序对C源程序进行预处理时用100替换标识符N
第7题
以下选项中的编译预处理命令行,正确的是( )。
#define PI 3.14
##define eps 0.001
#DEFINE TRUE
#define int INT
第8题
下面关于编译预处理的命令行,正确的是( )。
#define PAI 3.14
#Define Eps 0.00001
##DEFINE FALSE 0
第9题
有如下程序:
#include <stdio.h> #define D(x) 4*x+1 main() { int i=2,j=4; printf("%d\n",D(i+j)); }
程序运行后的输出结果是()。
25
13
9
12
第10题
有以下程序:
#include<stdio.h> #define S(x) x*x main() { int k=5,j=2; printf("%d,%d\n",S(k+j+2),S(j+k+2)); }
程序的运行结果是( )。
21,18
81,81
21,21
18,18
第11题
有以下函数:
#include <stdio.h> #define S(x) (x)*x*2 main() { int k=5,j=2; printf("%d,",S(k+j)); printf("%d\n",S(k-j)); }
98,18
39,11
39,18
98,11
第12题
#include <stdio.h> #define S(x) 4*(x)*x+1 main() { int k=5,j=2; printf("%d\n",S(k+j)); }
197
143
33
28
第13题
#include <stdio.h> #define PT 3.5 #define S(x) PT*x*x main() { int a=1,b=2; printf("%4.1f\n",S(a+b)); }
14.0
31.5
7.5
程序有错无输出结果
第14题
若有以下程序
#include <stdio.h> #define S(x) x*x #define T(x) S(x)*S(x) main() { int k=5,j=2; printf("%d,%d\n",S(k+j),T(k+j)); }
则程序的输出结果是()。
17,37
49,2401
17,289
49,289
第15题
#include <stdio.h> #define S(x) (x)*(x) #define T(x) S(x)/S(x)+1 main() { int k=3,j=2; printf("%d,%d\n",S(k+j),T(k+j)); }
11,2
25,2
11,12
25,26
第16题
以下程序:
#include <stdio.h> #define SUB(a) (a)-(a) main() { int a=2,b=3,c=5,d; d=SUB(a+b)*c; printf("%d\n",d); }
程序运行后的结果是()。
0
-12
-20
10
第17题
有以下程序
#include <stdio.h> #define SUB(X,Y) (X+1)*Y main() { int a=3,b=4; printf("%d\n",SUB(a++,b++)); }
20
16
第18题
#include <stdio.h> #define M 5 #define f(x,y)x*y+M main() { int k; k=f(2,3)*f(2,3); printf("%d\n",k); }
程序的运行结果是()。
22
41
100
121
第19题
#include <stdio.h> #define N 5 #define M N+1 #define f(x) (x*M) main() { int i1,i2; i1=f(2); i2=f(1+1); printf("%d %d\n",i1,i2); }
11 7
12 12
11 11
12 7
第20题
有以下程序;
#include <stdio.h> #define N 2 #define M N+1 #define MUN (M+1)*M/2 main() { printf("%d\n",MUN); }
8
5
6
第21题
#include<stdio.h> #define f(x) x*x*x main() { int a=3,s,t; s=f(a+1); t=f((a+1)); printf("%d,%d\n",s,t); }
10,64
10,10
64,10
64,64
第22题
#include <stdio.h> #define FNA(x) x*x #define FNB(x) x+x main() { int a=2,b=4; printf("%d,%d\n",FNA(FNB(a)),FNB(FNA(b))); }
8,16
16,32
8,32
16,16
第23题
设有宏定义:
#define IsDIV(k,n) ((k%n==1)?1:0)
且变量m已正确定义并赋值,则宏调用:
IsDIV(m,5)&&IsDIV(m,7)
为真时所要表达的是()。
判断m是否能被5或7整除
判断m是否能被5和7整除
判断m被5或7整除后是否余1
判断m被5和7整除后是否都余1
第24题
#include <stdio.h> #define F(x) 2.84+x #define PR(a) printf("%d",(int)(a)) #define PRINT(a) PR(a);putchar('\n') main() { PRINT(F(5)*2); }
15
11
第25题
#include<stdio.h> main() { int s,t,A=10; double B=6; s=sizeof(A); t=sizeof(B); printf("%d,%d\n",s,t); }
在VC++2010平台上编译运行,程序运行后的输出结果是()。
3,4
4,4
4,8
10,6
第26题
有以下程序段
int *p; p=______ malloc(sizeof(int));
若要求使p指向一个int型的动态存储单元,在横线处应填入的是()。
int
(int*)
int*
(*int)
第27题
#include <stdio.h> #include <stdlib.h> main() { int *a,*b,*c; a=b=c=(int*)malloc(sizeof(int)); *a=1; *b=2,*c=3; a=b; printf("%d,%d,%d\n",*a,*b,*c); }
3,3,3
2,2,3
1,2,3
1,1,3
第28题
#include <stdio.h> #include <stdlib.h> void fun(int*p1,int*p2,int*s) { s=(int*)malloc(sizeof(int)); *s=*p1+*p2; free(s); } main() { int a=1,b=40,*q=&a; fun(&a,&b,q); printf("%d\n",*q); }
42
1
第29题
#include <stdio.h> #include <stdlib.h> void fun(int*p1,int*p2,int*s) { s=(int*)malloc(sizeof(int)); *s=*p1+*p2; } main() { int a[2]={1,2}, b[2]={10,20},*s=a; fun(a,b,s); printf("%d\n",*s); }
2
第30题
#include <stdio.h> #include <stdlib.h> void fun(int*p1,int*s) { int *t; t=(int*)malloc(2*sizeof(int)); *t=*p1+*p1++; *(t+1)=*p1+*p1; s=t; } main() { int a[2]={1,2}, b[2]={0}; fun(a,b); printf("%d,%d\n",b[0],b[1]); }
2,6
0,0
2,4
1,2
第31题
#include <stdio.h> #include <string.h> #include <stdlib.h> main() { char*p1,*p2; p1=p2=(char*)malloc(sizeof(char)*10); strcpy(p1,"malloc"); strcpy(p2,p1+1); printf("%c%c\n", p1[0], p2[0]); }
aa
ma
am
mm
选择题(1 - 31题,共计100分)