首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; int main(){ int sum=0: for(int i=1;i
有如下程序: #include using namespace std; int main(){ int sum=0: for(int i=1;i
admin
2016-09-20
44
问题
有如下程序:
#include
using namespace std;
int main(){
int sum=0:
for(int i=1;i<4;i++){
for(int j=i;j<4;j++)sum+=j;
}
cout<
return 0;
}
运行时的输出结果是( )。
选项
A、15
B、17
C、16
D、14
答案
D
解析
外层for循环中,i的取值为1、2、3;内层for循环中,j的初始值为j,所以i=1时,i取值1、2、3,sum=0+1+2+3=6;i=2时,i取值2、3,sum=6+2+3=11;i=3时,j取值3,sum=11+3=14;答案选D选项。
转载请注明原文地址:https://kaotiyun.com/show/udNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
【】是按照程序语句行的自然顺序,依次执行语句。
若有如下程序:#include<iostream>usingnamespacesstd;ints=0;classsample,{staticintn;public:
下列关于类的访问权限的描述中,()是错误的。
以下内容属于存储在计算机内有结构的数据集合的是()。
在软件开发中,下面的任务不属于设计阶段的是______.
下面概念中,不属于面向对象方法的是______.
下列有关指针的用法中错误的是()。
以下类定义中可能会引起错误的语句是classA{public:~A(){}//1inti;//2private:
当要使用ostrstream流类定义一个流对象并联系一个字符串时,应在文件开始处使用#include命令,使之包含()文件。
随机试题
简述汇率波动受哪些因素的影响。
支气管哮喘发作时动脉血气分析PaO2降低,PaCO2正常或升高,最可能的表示是
迄今为止发展最快、渗透性最强、应用关键技术最广泛的行业是( )。
财务限制条款是防止公司的财务状况出现恶化的限制条款,其内容包括()。
有价证券的二级市场是指()。
“穿衣服、系鞋带”属于独立自主性教育中()的基本内容。
Youshouldspendnomorethan20minutesonthistask.Youandyourfamilyhaddinnerinarestaurantafewnightsago.The
WhenMr.Greenwasawayonbusiness,hisneighborgavehiswifea(n)______withthehousework.
Lemonadeisa(n)______drink.Lemonadeisnotanewdrink.It______.
Tomwastheonlyoneofthestudentswho________namedOutstandingStudent.
最新回复
(
0
)