第23294题 单选
C++枚举法查找数组最大值索引程序的横线处应填写的代码是?
#include <iostream>
using namespace std;

int main() {
    int arr[] = {3, 7, 2, 9, 5};
    int maxIndex = 0;
    for (int i = 1; i < 5; i++) {
        // 此处为待填横线位置
        {
            maxIndex = i;
        }
    }
    cout << maxIndex;
    return 0;
}
A

if (arr[maxIndex] > arr[i])

B

if (arr[i]-1 > arr[maxIndex])

C

if (arr[i]+1 > arr[maxIndex])

D

if (arr[i] > arr[maxIndex])

程序运行统计
暂无判题统计