-1

这是我第一次使用 Eclipse 进行 C++ 编程,但遇到了问题。我已经包含“time.h”,但错误(函数'srand'无法解决)仍然出现。请帮我!非常感谢

#include "iostream"
#include "time.h"
using namespace std;
#define MAX 100
void InputArray(int a[],int n)
{

    srand((unsigned)time(NULL)); //error here Function 'srand' could not be solved
        a[0]=rand()%10; //and here 
        for(int i=1; i<n; i++)
            a[i]=a[i-1] + rand()%10 + 1;
}
int main() {
    int a[MAX], n;
    InputArray(a,n);
    return 0;
}
4

1 回答 1

4

你忘了

#include <stdlib.h>
于 2012-07-19T07:56:21.107 回答