首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include #include void fun(int*p1,int*p2,int*s){ s=(int*)calloc(1,sizeof(int)); *s=*p1+*p2;free(s);}
有以下程序 #include #include void fun(int*p1,int*p2,int*s){ s=(int*)calloc(1,sizeof(int)); *s=*p1+*p2;free(s);}
admin
2020-05-19
18
问题
有以下程序
#include
#include
void fun(int*p1,int*p2,int*s){
s=(int*)calloc(1,sizeof(int));
*s=*p1+*p2;free(s);}
main(){
int a[2]={1,2},b[2]={40,50},*q=a;
fun(a,b,q);
pfintf("%d\n",*q);}
程序运行后的输出结果是
选项
A、41
B、42
C、0
D、1
答案
A
解析
主函数定义数组a,b,q指向数组a,调用tun函数以后形参接收实参的数据,p1和p2指向数组a和b,同时s指向数组a,在fun函数中改变了s的指向和赋值,但是在程序调用结束之间形参空间全部释放,因此对于s的指向改动不会对主函数参数构成影响。因此主函数中数去*q的值仍然为1。
转载请注明原文地址:https://kaotiyun.com/show/1rCp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
设chara[]=’’xyz’’,b[]={’x’,’y’,’z’};,则关于数组长度的叙述中正确的是()。
若intyear=一2009,*p=&year;以下不能使变量year中的值增至2010的语句是()。
没有编译错误的程序段是()。
若有定义语句:intx=12,y=8,z;,在其后执行语句z=0.9+x/y;,则z的值为()。
有以下程序:#includemain(){chars[]=“abode”;s+=2;prinff(“%d\n”,s[0]);}程序的运行结果是()。
有以下程序:#includemain(){charch[]=“uvwxyz”,*pc;pc=ch;prinff(“%c\n”,*(pc+5));}程序的运行结果是()。
下列选项中属于面向对象设计方法主要特征的是()。
编写函数fun,它的功能是计算:s=s作为函数值返回。在C语言中可调用log(n)函数求In(n)。log函数的引用说明是:doublelog(doublex)。例如,若m的值为:20,fun函数值为:6.506
关系的实体完整性要求关系中不能为空的属性是()。
不属于对象构成成份的是
随机试题
函数+lg(1+x)的定义域为________.
阿托品不具有的作用是
病人,女,69岁,心前区疼痛5小时,心电图示急性广泛前壁心肌梗死伴室性早搏。入院体检:气急不能平卧,血压130/80mmHg,心率176次/分。两肺散在细湿啰音,伴少许哮鸣音。肝颈静脉回流征阴性。心电图示病人存在室性心动过速,应首先选用哪项治疗措施(
下列关于ELISPOT与ELISA的说法,正确的是
预后最差的肺癌是
不属于宫内节育器的并发症的是()。
简述个体自我意识从产生到成熟所经历的三个时期。
调查显示,新闻记者的职业和网络关系密切,但只占上网人数的1.8%;与大量青少年学生网民(占总数的19.3%)相比,教师和党政企事业单位的领导干部上网太少(分别占网民总数的5%和3.4%);与月收入500元以下和500~1000元的人群(分别占网民总数的21
Consumersandproducersobviouslymakedecisionsthatmoldtheeconomy,butthereisathirdmajor【C1】______toconsider,therol
Whenheappliedfora______intheofficeofthelocalnewspaperhewastoldtoseethemanager.
最新回复
(
0
)