下标n没有初值,超出了数组最大下标,就崩溃了,
int main()
{
int iNumber, n=0, k, PA, PB, PC, PD, PE, PF;
int yArray[30] = { 5, 4, 6, 8, 7, 9, 12, 10, 12, 16, 20, 15, 19, 21, 18, 21, 33, 20, 34, 25, 23, 36, 27, 28, 22, 35, 31, 30, 34, 33 };
int nArray[30] = { 2, 5, 9, 10, 3, 11, 15, 13, 14, 17, 13, 14, 9, 15, 8, 23, 19, 21, 30, 24, 17, 26, 25, 30, 29, 29, 24, 32, 33, 31 };
int countA = 0;
int countB = 0;
int countC = 0;
int countD = 0;
int countE = 0;
int countF = 0;
for (iNumber = 1; iNumber <= 100000; iNumber++)
{
while (n < 30)
{
srand((unsigned int)time(NULL));//设置随机数种子
k = rand() % 2;
if (k == 1)//1代表yes
{
n = yArray[n];
}
else//否则代表no
{
n = nArray[n];
}
}