大家能看看这个程序出错在哪里吗?本人菜鸟,求各位大神罩罩
#include<iostream>#include<stdio.h>
#include<cstdio>
#include<cstring>
#include<fstream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
cout << "请依次输入v,d,T,T_start,T_end"<<endl;
int v;
double d;
cin >> v >> d;
int A = 0, B = 0;
int T, T_start, T_end;
cin >> T >> T_start >> T_end;
srand(int(time(0)));
int f[5] = { 0,5,10,15,20 };
int num=0;
int t_left[10000];
double y_left[10000];
double s_left[10000];
while (T >= T_start&&T <= T_end)
{
int j_num;
int i_num;
int taxi;
int w;
j_num = rand() % 16;
i_num = j_num + num;
A = A + j_num;
int **matrix = (int **) new int *[i_num];
for (int i = 0; i < i_num; i++)
matrix[i] = new int[5];
double * s = new double[i_num];
double *Y = new double[i_num];
for (i = 0; i < j_num; i++)
{
matrix[i][0] = rand() % 11 + 5; //t
matrix[i][1] = rand() % 31; //S
int temp = rand() % 5;
matrix[i][2] = f[temp]; //f
s[i] = (rand() % 100)*0.01; //s
matrix[i][3] = 0; //F
matrix[i][4] = 1; //bool
}
int j;
for (i = j_num,j = 0; i < i_num; i++,j++)
{
matrix[i][0] = t_left[j];
s[i] = s_left[j];
Y[i] = y_left[j];
matrix[i][4] = 1;
}
if (540 >= T&&T >= 180 || 1020 <= T&&T <= 1080)
taxi = rand() % 6 + 5;
else
taxi = rand() % 11 + 10;
w = rand() % 11 + 5;
for (i = 0; i < j_num; i++)
{
if (matrix[i][1] <= 3)
matrix[i][3] = 8;
else
matrix[i][3] = 8 + 2 * (matrix[i][1] - 3);
Y[i] = matrix[i][3] + B*matrix[i][0] + matrix[i][2] - s[i] * d -matrix[i][1]*d;
}
int count = 0;
for (i = 0; i < i_num; ++i)
{
if (Y[i]>w&&matrix[i][4]==1)
{
count++;
}
}
int one;
double hehe;
for (i = 0; i < i_num;i++)
for (j = 0; j < i_num - i - 1; j++)
{
if (Y[j] < Y[j + 1])
{
one = matrix[j][0];
matrix[j][0] = matrix[j+1][0];
matrix[j + 1][0] = one; //t
hehe = s[j];
s[j] = s[j + 1];
s[j + 1] = hehe;
hehe = Y[j];
Y[j] = Y[j + 1];
Y[j + 1] = hehe;
}
}
if (count >= taxi)
{
for (i = 0; i < taxi; i++)
{
matrix[i][4] = 0;
double temp = s[i] / v;
if (temp <= matrix[i][0])
B++;
}
for (i = taxi; i < i_num; i++)
{
matrix[i][0]--;
if (matrix[i][0] == 0)
matrix[i][4] = 0;
}
}
else
{
for (i = 0; i < count; i++)
{
matrix[i][4] = 0;
double temp = s[i] / v;
if (temp <= matrix[i][0])
B++;
}
for (i = count; i < i_num; i++)
{
matrix[i][0]--;
if (matrix[i][0] == 0)
matrix[i][4] = 0;
}
}
for (i = 0,j=0; i < i_num; i++,j++)
{
if (matrix[i][4] == 1)
{
y_left[j] = Y[i];
s_left[j] = s[i];
t_left[j] = matrix[i][0];
num++;
}
}
delete[]s;
delete[]Y;
for (i = 0; i < i_num; i++)
delete[] matrix[i];
delete[] matrix;
T = T + 1;
}
double x =(double) B / A;
cout << B << " " << A;
cout << endl << x;
int h;
cin >> h;
}