debug assertion failed
程序代码:
#include<iostream> #include<fstream> #include<ctime> #include<string> #include<stdlib.h> using namespace std; const int lane = 1000; const int v_max = 18; int v[lane]; int car_num; int p[200]; void inicars() { FILE *gg; gg = fopen("t-s.txt", "a"); int i, j, k; int temp_1, temp_2 = 0; int n = 0; for (i = 0; i < lane; i++) v[i] = -1; for (i = 0; i < car_num; i++) { v[temp_2] = rand() % (v_max + 1); temp_2 = temp_2 + 6; //表示的速度是车尾速度,v[位置]=speed } for (i = 0; i<lane; i++) { if (v[i] >= 0) { p[n] = i; // n++; } } for (i = 0; i < car_num; i++) fprintf(gg,"num=%2d,loc=%2d,speed=%2d\n",i,p[i],v[p[i]] ); // fprintf(gg, "\n"); } void main() { for (car_num = 10; car_num < 20; car_num + 10) { srand(time(NULL)); inicars(); } }