Dotcpp  >  试卷列表  >  C语言编译预处理和动态存储分配

C语言编译预处理和动态存储分配


第1题

以下叙述中正确的是( )。

共 1 分 

第2题

以下关于编译预处理的叙述中错误的是( )。

共 1 分 

第3题

以下关于宏的叙述中正确的是( )。

共 1 分 

第4题

以下关于宏的叙述错误的是( )。

共 1 分 

第5题

以下叙述中错误的是( )。

共 3 分 

第6题

若程序中有宏定义行:#define N 100则以下叙述中正确的是()。

共 1 分 

第7题

以下选项中的编译预处理命令行,正确的是( )。

共 3 分 

第8题

下面关于编译预处理的命令行,正确的是( )。

共 3 分 

第9题

有如下程序:

1
2
3
4
5
6
7
#include <stdio.h>
#define D(x)4*x+1
main()
{
int i=2,j=4;
printf("%d\n",D(i+j));
}

程序运行后的输出结果是()。

共 3 分 

第10题

有以下程序:

1
2
3
4
5
6
7
#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));
}

程序的运行结果是( )。

共 3 分 

第11题

有以下函数:

1
2
3
4
5
6
7
8
#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));
}

程序运行后的输出结果是()。

共 3 分 

第12题

有以下程序:

1
2
3
4
5
6
7
#include <stdio.h>
#define S(x)4*(x)*x+1
main()
{
int k=5,j=2;
printf("%d\n",S(k+j));
}

程序运行后的输出结果是()。

共 3 分 

第13题

有以下程序:

1
2
3
4
5
6
7
8
#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));
}

程序运行后的输出结果是()。

共 3 分 

第14题

若有以下程序

1
2
3
4
5
6
7
8
#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));
}

则程序的输出结果是()。

共 3 分 

第15题

若有以下程序

1
2
3
4
5
6
7
8
#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));
}

则程序的输出结果是()。

共 3 分 

第16题

以下程序:

1
2
3
4
5
6
7
8
#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);
}

程序运行后的结果是()。

共 3 分 

第17题

有以下程序

1
2
3
4
5
6
7
#include <stdio.h>
#define SUB(X,Y)(X+1)*Y
main()
{
int a=3,b=4;
printf("%d\n",SUB(a++,b++));
}

程序运行后的输出结果是()。

共 4 分 

第18题

有以下程序:

1
2
3
4
5
6
7
8
9
#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);
}

程序的运行结果是()。

共 4 分 

第19题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
#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);
}

程序的运行结果是()。

共 4 分 

第20题

有以下程序;

1
2
3
4
5
6
7
8
#include <stdio.h>
#define N 2
#define M N+1
#define MUN (M+1)*M/2
main()
{
printf("%d\n",MUN);
}

程序运行后的输出结果是()。

共 4 分 

第21题

有以下程序:

1
2
3
4
5
6
7
8
9
#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);
}

程序运行后的输出结果是()。

共 4 分 

第22题

有以下程序:

1
2
3
4
5
6
7
8
#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)));
}

程序运行后的输出结果是()。

共 4 分 

第23题

设有宏定义:

1
#define IsDIV(k,n) ((k%n==1)?1:0)

且变量m已正确定义并赋值,则宏调用:

1
IsDIV(m,5)&&IsDIV(m,7)

为真时所要表达的是()。

共 1 分 

第24题

有以下程序:

1
2
3
4
5
6
7
8
#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);
}

程序运行后的输出结果是()。

共 4 分 

第25题

有以下程序

1
2
3
4
5
6
7
8
9
#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平台上编译运行,程序运行后的输出结果是()。

共 4 分 

第26题

有以下程序段

1
2
int *p;
p=______ malloc(sizeof(int));

若要求使p指向一个int型的动态存储单元,在横线处应填入的是()。

共 4 分 

第27题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
#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);
}

程序运行后的输出结果是()。

共 4 分 

第28题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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);
}

程序运行后的输出结果是()。

共 4 分 

第29题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
#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);
}

程序运行后的输出结果是()。

共 4 分 

第30题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#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]);
}

程序运行后的输出结果是()。

共 4 分 

第31题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
#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]);
}

程序的运行结果是()。

共 4 分