单选题 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并计算二者的和。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考