当前位置:IT认证>计算机二级

问题:

[单选] 有以下程序:
#include<stdio.h>
#include<stdlio.h>
void fun(int*pl,int*p2,int*s)
{  s=(int*)malloc(sizeof(int));
 *s=*pl+*p2;
 free(s);
}
main(  )   
{ int a=1,b=40,*q=&a;
 fun(&a,&b,q);
 printf("%d",*q);
}   
程序运行后的输出结果是(  )。

A . 42
B . 0
C . 1
D . 41

以下程序的主函数中调用了在其面前定义的fun函数 #include<stdio.h>...main(  ){double a[15],k; k=fun(a);    ... }则以下选项中错误的fun函数首部是(  )。    、 double fun(double a[l5])。 double fun(double  *a)    。。 double fun(double a[])。 double fun(double  a)。 以下定义数组的语句错误的是(  )。 int num[]={1,2,3,4,5,6};。 int num[][3]={{1,2},3,4,5,6};。 int num[2][4]={{1,2},{3,4},{5,6}};。 int num[][3]={1,2,3,4,5,6}; 。 若有定义语句:“int year=2009,*p=&year;”,以下不能使变量year中的值增至2010的语句是(  )。 *p+=1;   。 (*p)++;。 ++(*p);  。 *++P。 有以下程序: #include<stdio.h>main(  ){  int a=-2,b=0;  while(a++&&++b);  printf("%d,%d",a,b); }程序运行后的输出结果是(  )。 1,3   。 0,2。 0,3   。 1,2。 若有定义和语句:int a,b;scanf("%d,%d",&a,&b);以下选项中的输人数据,不能把值3赋给变量a、5赋给变量b的是(  )。 3,5,   。 3,5,4。 3,5   。 3   5。 有以下程序:
#include<stdio.h>
#include<stdlio.h>
void fun(int*pl,int*p2,int*s)
{  s=(int*)malloc(sizeof(int));
 *s=*pl+*p2;
 free(s);
}
main(  )   
{ int a=1,b=40,*q=&a;
 fun(&a,&b,q);
 printf("%d",*q);
}   
程序运行后的输出结果是(  )。
参考答案:

  参考解析

Fun函数功能是新开辟内存空间存放a和b的地址,q的地址并没有变化,所以应该还是指向地址a。

在线 客服