题解 | #获取数组最值#
获取数组最值
http://www.nowcoder.com/practice/53d110f6cdd14f21af285698f975b59c
using namespace std;
int main() {
int arr[6] = { 0 };
int len = sizeof(arr) / sizeof(int);
for (int i = 0; i < len; i++) {
cin >> arr[i];
}
int min=arr[0];
int max=arr[0];
for(int i=0;i<len;i+=1){
if(min>arr[i]){
min=arr[i];
}
if(max<arr[i]){
max=arr[i];
}
}
printf("%d %d\n",min,max);
// write your code here......
return 0;
}