首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; int main(){ int a[6]={23, 15, 64, 33, 40, 58}; int s1, s2; s
有如下程序: #include<iostream> using namespace std; int main(){ int a[6]={23, 15, 64, 33, 40, 58}; int s1, s2; s
admin
2017-10-17
24
问题
有如下程序:
#include<iostream>
using namespace std;
int main(){
int a[6]={23, 15, 64, 33, 40, 58};
int s1, s2;
s1, s2=a[0];
for(int*p=a+1; p<a+6; p++) {
if(s1>*p)s1=*p;
if(s2<*p)s2=*p;
}
cout<<s1+s2<<end1;
return 0;
}
运行时的输出结果是( )。
A) 23
B) 58
C) 64
D) 79
选项
A、
B、
C、
D、
答案
D
解析
变量s1和s2的初值都等于23,那么在执行第一次for循环时,*p的值等于15,它小于23,所以把15赋给变量s1;执行第二次for循环时,*p的值等于64,它大于23,所以把64赋给变量s2;而数组a中a[2]后面的元素的值都大于15,小于64,因而变量s1,s2的值不会再发生变化,最终值为15+6=79,所以程序输出79。
转载请注明原文地址:https://kaotiyun.com/show/FJAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
关于纯虚函数和抽象类的描述中,错误的是()。
已知大写字母A的ASCII码值是65,小写字母a的ASCII码是97,则用八进制表示的字符常量’\101’是
下列叙述中正确的是
有如下程序:#include<iostream>usingnamespacestd;classA{public:A(){cout<<"A";}~A(){cout<<"~A";)
下列说法中错误的是()。
在表达式x+y*z中,+是作为成员函数重载的运算符,*是作为非成员函数重载的运算符。下列叙述中正确的是,
有如下类声明:classXA{intx;public:XA(intn){x=n;}};classXB:publicXA{
在双目运算符中需要声明其右操作数时,完成的是【 】重载,而需要声明全部操作数时,完成的是【 】重载。
数据库系统的核心是
( )是以一种完全通用的方法来设计函数或类而不必预先说明将被使用的每个对象的类型。
随机试题
PublicperceptionofsuccessintheU.S.mightbetotallymisguided.While92%ofpeoplebelieveotherscaremostaboutfame
常作为尿路感染筛查试验的是
[2006年第56题]补偿热水管道热胀冷缩的措施,下列哪条不正确?
操作系统的基本功能是()。
顾客所关心的问题不包括()。
图纸会审时,对于施工的技术方面主要审查内容有()。
再贴现率是一国利率体系中的基准利率。( )
在确定最佳现金持有量时,成本分析模式和存货模式均需考虑的因素是()。
中国共产党和各民主党派合作的首要前提和根本保证是()
YouaregoingtoreadatextaboutChina’stradeachievements,followedbyalistofexamples.Choosethebestexamplefromthe
最新回复
(
0
)