内部编译器错误,怎么搞,求解答


#include
using namespace std;

template<class T>
T min(T a[], int n)
{
    int i;
    T minValue = a[0];
    for (i = 1;i < n, i++)
        if (minValue > a[i])
            minValue = a[i];
    return minValue;
}

int main()
{
    int a[] = { 1,3,0,2,7,6,4,5,2 };
    double b[] = { 1,2,-3,4,6,8,9,8 };
    cout << "a数组的最小值为:" << min(a, 9) << endl;
    cout << "b数组的最小值为:" << min(b, 4) << endl;

    return 0;
}

i < n 后面要是分号,你现在是逗号

 
#include<iostream>
using namespace std;
template<class T>
T min(T a[], int n)
{
    int i;
    T minValue = a[0];
    for (i = 1;i < n; i++) // for 循环 修改
        if (minValue > a[i])
            minValue = a[i];
    return minValue;
}
int main()
{
    int a[] = { 1,3,0,2,7,6,4,5,2 };
    double b[] = { 1,2,-3,4,6,8,9,8 };
    cout << "a数组的最小值为:" << min(a, 9) << endl;
    cout << "b数组的最小值为:" << min(b, 4) << endl;
    return 0;
}

for循环中n后面分号写成了逗号

For循环错了


for (i = 1; i < n; i++)