全部题库 / C++ / 试题详情
单选题 C++
2013-08-04

有如下程序:
#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;
}
运行时的输出结果是(  )。

A.23
B.58
C.64
D.79

参考答案

D

答案解析

D。【解析】根据程序的意思,找出数组a中最大值s1和最小值s2并计算二者的和。

你可能感兴趣的试题