首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下面的程序: #include<iostream.h> void main() {int x; cin>>x; if(x++>5) cout<<x<<end1; else cout<<x-
阅读下面的程序: #include<iostream.h> void main() {int x; cin>>x; if(x++>5) cout<<x<<end1; else cout<<x-
admin
2019-06-12
56
问题
阅读下面的程序:
#include<iostream.h>
void main()
{int x;
cin>>x;
if(x++>5)
cout<<x<<end1;
else
cout<<x--<end1;
}
如果两次执行上述程序,且键盘输入分别为4和6,则输出结果分别是( )。
选项
A、4,6
B、3,6
C、4,7
D、5,7
答案
D
解析
此题首先读入数值4赋给变量x,因为x++>5不成立,因为“++”后缀,之后x的值变为5,执行语句cout<<x-<<end1;输出:5,之后x的值变为4。当读入的数值是6时,因为x++>5成立,所以执行语句cout<<x<<end1;输出7。
转载请注明原文地址:https://jikaoti.com/ti/qJA0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classA{public:staticinta:voidinit(){a=1;}A(inta=2){i
类MyClass的定义如下:classMyClass{public:MyClass(){Value=0.)SetVariable(inti){value=i;}private:int
有如下类声明:classMyBASE{intk=public:voidsct(intn){k=n;}intget()const{returnk;}};
函数swap(a,n)可完成对a数组从第1个元素到第n个元素两两交换。其中b[0]=1;b[1]=2;swap(b,2)。在运行调用函数中的语句后,b[0]和b[1]的值分别为()。
执行下列程序段以后程序的输出是__________。voidadd(int&x){x++:}intmain(){inty=3:add(y);cout
执行下列语句后,输出结果为__________。inta=0,b=2,c=3;switch(a){case0:switch(b){case1:co
有如下程序:#includeusingnamespacestd:classTestClass1{public:TestClass1(){cout
有如下程序:#includevoidmain(){charstr[2][5]={“1234”,“5678”},*p[2];imij,s=0;for(i=0;i
在关系模型中,二维表的行称为_____________。
随机试题
A.TTGACAB.TATAATC.TATAD.AATAAA真核生物Hogness盒序列是指
髁状突颈部骨折常伴有()
建设工程监理工作中,动态跟踪项目执行情况并处理好工程索赔等事宜,属于目标控制的()措施。
钢结构焊接验收时,二级焊缝不得有()等质量缺陷
阿拉瓜利河位于巴西亚马孙河流域的北部,注入大西洋,全长只有220千米,下游河道宽约2千米,且河床较浅,沿河多沼泽。在特定时间,河口会出现涌潮。浩浩荡荡的潮水从河口沿河道逆流而上60千米,时速30余千米,潮高可达2~4米。下图示意阿拉瓜利河的中下游位置。据此
学生初学英文字母时,常常将其读成汉语拼音。这属于()。
根据下列资料,回答问题。2013年全国社会物流总额197.8万亿元,同比增长9.5%,增幅比上年回落0.3个百分点。分季度看,一季度增长9.4%,上半年增长9.1%,前三季度增长9.5%。其中,工业品物流总额181.5万亿元,同比增长9.7%,增
在不同历史条件下,人们报效祖国的方式往往是不同的。不论以什么样的方式来报效祖国,都要
a.それでb.それにc.それともd.それでもe.それではA「どうして土曜日にパーティーに行かないの?」B「パーティーは嫌いです。________知っている人は誰も行かないみたいだし。」
Whathedoes,healwaysdoesitwell,thoughhehassomedifficulties.
最新回复
(
0
)