首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >c++程序在中间暂停,控制台处于进入模式

c++程序在中间暂停,控制台处于进入模式
EN

Stack Overflow用户
提问于 2014-08-31 10:37:49
回答 1查看 35关注 0票数 0

我正在写一个程序,允许用户制作一个3对3梦幻生物的锦标赛。锦标赛的实际战斗部分运行良好,但在我的最后一行cout代码说谁赢得了最后一场比赛之后,当我试图输出排名时,会出现一个空格,就像出现cin时一样,但如果输入任何内容,则什么也不会发生。我相信有更好的方法来绘制我的地图,但我不能理解为什么我的cout中没有变量的顶行也不会出现。这只是战斗结束后代码的一部分。points和standing都是int,int map。

代码语言:javascript
复制
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;
EN

回答 1

Stack Overflow用户

发布于 2014-08-31 10:49:29

for (int j=1; j<7;i++)是一个无限循环--您最后可能指的是j++。因此,永远不会执行cout行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25588515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档