int secondMaxIndex(int *arr, int n)
{/*
1.求整形数组中第二大元素的下标(15分)
n表示数组长度
如数组中元素为81 12 42 67 9 88,返回0
*/
int max = arr[0]>arr[1]?arr[0]:arr[1];
int maxIndex =arr[0]>arr[1]?0:1;
int second = arr[0]<arr[1]?arr[0]:arr[1];
int secondIndex =arr[0]<arr[1]?0:1;
for (int i = 2; i < n; i++) {
if (arr[i] > max) {
second = max;
secondIndex = maxIndex;
max = arr[i];
maxIndex = i;
}else if(arr[i] > second){
second = arr[i];
secondIndex = i;
}
}
return secondIndex;
}
int sumOfNumber(int a,int n)