崩潰,我有這個簡單的C++程序C++程序在運行時
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <vector>
using namespace std;
int aleator(int n)
{
return (rand()%n)+1;
}
int main()
{
int r;
int indexes[100]={0};
// const int size=100;
//int a[size];
std::vector<int>v;
srand(time(0));
for (int i=0;i<25;i++)
{
int index = aleator(100);
if (indexes[index] != 0)
{
// try again
i--;
continue;
}
indexes[index] = 1;
cout << v[index] ;
}
cout<<" "<<endl;
system("pause");
return 0;
}
但在運行時它崩潰了,所以我就用「發送錯誤報告」和「不發送」的錯誤。我做錯了什麼?謝謝!
如果它在任何其他時間墜毀,這將是有趣的。 – 2010-06-05 19:40:28