原文 Ivor Horton [Beginning Visual C++2008 ]
#include<iomanip>
#include<iostream>
using std::cout;
using std::endl;
using std::setw;
double& lowest(double values[],int count);
int main()
{
double array[] = {3.0,10.0,1.5,15.0,2.7,23.0,4.5,12.0,6.8,13.5,2.1,14.0};
int len = sizeof(array)/sizeof(array[0]);
cout << endl;
for(int i =0;i<len;i++){
cout<<setw(5)<<array[i];
}
lowest(array,len) = 6.9;
lowest(array,len) = 7.9;
cout << endl;
for(int i =0;i<len;i++){
cout<<setw(5)<<array[i];
}
cout << endl;
}
double& lowest(double a[],int count)
{
int j = 0;
for(int i=0;i<count;i++)
{
if(a[j]>a[i])
j=i;
}
return a[j];
}