单选题
C++
题号 #2250985
有如下程序:
#include<iostream>
usingnamespacestd;
intmain( ){
inta[6]={23,15,64,33,40,58};
ints1,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<<endl;
return0;
}
运行时的输出结果是( )。
参考答案
D
答案解析
D。【解析】根据程序的意思,找出数组a中最大值s1和最小值s2并计算二者的和。
你可能感兴趣的试题
A.10
B.16
C.26
D.36
A.5
B.6
C.7
D.8
A.5
B.7
C.9
D.12