首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
以下程序的输出结果是 #include<iostream.h> void main( ) {int x=1,y=3; cout << x++ << ","; {int x
以下程序的输出结果是 #include<iostream.h> void main( ) {int x=1,y=3; cout << x++ << ","; {int x
admin
2013-05-30
7
问题
以下程序的输出结果是 #include<iostream.h> void main( ) {int x=1,y=3; cout << x++ << ","; {int x=0;x+=y*2; cout <<X <<"," <<y << ","; } cout << x <<","<< y; }
选项
A、1,6,3,1,3
B、1,6,3,6,3
C、1,6,3,2,3
D、1,7,3,2,3
答案
4
解析
cout<<x++;语句中,程序先输出x的值,然后再加1,所以结果为1,此时x的值为2;在 int x=0;x+=y*2;语句中,将0的值赋给x,然后再运算 x+=y*2的值,结果为x=6(此时x的值为局部变量),y的值不变,在最后在执行了x语句后的值,所以应为2。
转载请注明原文地址:https://kaotiyun.com/show/XTNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下程序的输出结果是【】。chars[]="XYZQ";voidmain(){char*p;for(p=s;p<s+4;p++)cout<<p<<end1;}
C++语言做了很多改进,下列描述中_______使得C语言发生了质变,即从面向过程变成面向对象。
结构化程序设计主要强调的是()。
若以非成员函数形式,为类Bounce重载“!”运算符,其操作结果为一bool型数据,则该运算符重载函数的原型是【】。
若a=12,b=14,c=0,则表达式((y=(a>b)?a:b)>c)?y:c的值为【】
有以下程序#include<iostream>usingnamespacestd;classMyClass{public:MyClass(intn){number=n;}//拷贝的构造函数MyClass(MyClas
下列叙述中正确的是()。
面向对象的程序设计方法中涉及的对象是系统中用来描述客观事物的一个【】。
下列函数中,对文件进行写操作的是()。
假定一个一维数组的定义为“chara[8],b;”若把该数组最后一个元素赋值给b应该采取的表达式为:【】。
随机试题
通过缩减政府的支出,或者减少企业和个人的可支配收入的紧缩性的财政政策是()
下列各种反应中,经治疗可得到有效逆转的是()。
A、羧甲基纤维素钠B、微晶纤维素C、滑石粉D、乙基纤维素E、乙醇润滑剂是
小剂量阿司匹林预防血栓生成的机制是
采用预制板的屋面在板面灌缝施工中要求是()
有一梯形断面的引水渠道,边坡系数m=1.5,粗糙系数n=0.025,底坡i=0.0004,底宽b=5m,渠中通过的流量Q=8m3/s,在求解渠道的正常水深h0时,下述说法和结果中正确的是()。
企业在连续提取坏账准备的情况下,“坏账准备”科目在期末结账前如为贷方余额,其反映的内容是()。
下列句子没有语病的一项是()。
IntelligentandEnergy-savingSolarHomeA)Ifsomegroupgaveoutawardsfortheleastenergy-efficientstructures—thewaythose
IsHeadphoneGoodforWork?A)MarissaYuworksinabusyoffice,surroundedby120co-workersinamostlyopenspace.Yetwhens
最新回复
(
0
)