我写了一个 C++ 程序,实际上它是一个游戏。我收到了这个错误:
Windows 在 bla bla 中触发了断点...
有人能帮我吗?
那是代码,但在 AAA 行发生错误:
void r_motions(char **map,int size)
{
int parameter_i,parameter_j,player_i,player_j;
int *r_location_i = new int[1],*r_location_j = new int[1];
player_finder(map,size,player_i,player_j);
int r_num = robots_finder(map,size,r_location_i,r_location_j);
for(int i=1;i<=r_num;i++)
{
parameter_i =0;
parameter_j =0;
if(r_location_i[i]>player_i) parameter_i = -1;
if(r_location_i[i]<player_i) parameter_i = 1;
if(r_location_j[i]>player_j) parameter_j = -1;
if(r_location_j[i]<player_j) parameter_j = 1;
map[r_location_i[i]][r_location_j[i]] = '.';
r_location_i[i] = r_location_i[i]+parameter_i;
r_location_j[i] = r_location_j[i]+parameter_j;
}
for(int i=1;i<=r_num;i++)
{
switch (map[r_location_i[i]][r_location_j[i]])
{
case '.':
map[r_location_i[i]][r_location_j[i]] = '+';
break;
case '@':
map[r_location_i[i]][r_location_j[i]] = '+';
print_map(map,size);
cout << "Robots win ." << endl;
sleep(1000);
exit(1);
break;
case '+':
map[r_location_i[i]][r_location_j[i]] = '*';
break;
case '*':
map[r_location_i[i]][r_location_j[i]] = '*';
break;
default: cout << "what r u doin' ??";
break;
}
}
}