int[] a = { 2, -6, 9, 1, 3 };
int[] b = { -9, 5, 7, 3 };
int maxIndex1 = 0;
int minIndex1 = 0;
for (int i = 1; i < a.Length; i++) {
if (a [maxIndex1] < a [i]) {
maxIndex1 = i;
}
if (a [minIndex1] > a [i]) {
minIndex1 = i;
}
}
Console.WriteLine ("a数组最小值是:" + a [minIndex1]);
int maxIndex2 = 0;
int minIndex2 = 0;
for (int i = 1; i < b.Length; i++) {
if (b [maxIndex2] < b [i]) {
maxIndex2 = i;
}
if (b [minIndex2] > b [i]) {
minIndex2 = i;
}
}
Console.WriteLine ("b数组最小值是:" + b [minIndex2]);
// 求两数组最大值
int result1 = a [maxIndex1] > b [maxIndex2] ? a [maxIndex1] : a [maxIndex2];
Console.WriteLine ("最大值是:" + result1);
// 求两数组最小值
int result2 = a [minIndex1] < b [minIndex2] ? a [minIndex1] : b [minIndex2];
Console.WriteLine ("最小值是:" + result2);