這是我第一次使用Eclipse進行C++編程,而且我遇到了問題。我已經包含「time.h」,但錯誤(函數'srand'無法解決)仍然出現。請幫幫我!非常感謝函數'srand'無法解決? (我使用Ubuntu操作系統和Eclipse)
#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;
}
另外,請不要只是一味地添加代碼完全改變它的問題... – 2012-07-19 08:02:20
是否真的說「無法得到解決」 ? – 2012-07-19 08:02:43