C++求数组最大值和最小值
int main()
{
int datas[10] = {-1, 2, 3, 4, 5, 6, 7 ,8, 9, 10};
int max = 0;
int min = 0;
for(int i = 0; i < 10; ++i)
{
if(max < datas[i])
{
max = datas[i];
}
else
{
if(min > datas[i])
{
min = datas[i];
}
}
}
cout << max << " " << min << endl;
int wait;
cin >> wait;
return 0;
}