我正在编写一个程序,允许用户参加3对3幻想生物的锦标赛。比赛的实际战斗部分工作得很好,但是在我最后一次比赛之后,当我试图输出积分榜时,谁赢得了最后的战斗,就像有一个cin出现的空白区域,但如果输入任何东西没有任何反应。我确信有更多优雅的方式来做我的地图,但我不明白为什么即使我的cout没有变量的顶线也不会出现。这只是战斗结束后代码的一部分。 point和standing都是int,int maps。
for (int i=1; i<7;i++)
{
for (int j=1; j<7;i++)
{
if ((points[i]==points[j])&&(i!=j))
{
int tie=rand()%2;
if (tie==0)
{
points[i]=points[i]+1;
}
else
{
points[j]=points[j]+1;
}
}
}
}
for (int i=1;i<7;i++)
{
standing[(points[i])]=i;
}
map <int,int>::iterator k;
k=standing.begin();
cout << "These are the final standings. \n";
cout << "Please note fighters 1-3 are player 1 and \n";
cout << "4-6 are from player 2. \n";
cout << "In first place is fighter #" << k->second;
cout << " with " << k->first << "points \n";
k++;
cout << "In second place is fighter #" << k->second;
cout << " with " << k->first << "points \n";
k++;
cout << "In third place is fighter #" << k->second;
cout << " with " << k->first << "points \n";
return 0;
答案 0 :(得分:0)
for (int j=1; j<7;i++)
是一个无限循环 - 最后你可能意味着j++
。因此,cout
行永远不会执行。