标题:谁能帮我把这个程序加段循环上去,能让我一直循环这个程序
只看楼主
后卿
Rank: 4
来 自:网络
等 级:业余侠客
帖 子:297
专家分:295
注 册:2016-10-22
结帖率:82.28%
 问题点数:0 回复次数:3 
谁能帮我把这个程序加段循环上去,能让我一直循环这个程序
#include "touwenjian.h"
int main()
{
    int score=0;
    cout<<"请输入您的分数"<<endl;
    cin>>score;
    if (score>750||score<0)
    {
        cout<<"成绩输入不正确"<<endl;
    }
    else
    {
    cout<<"您的分数为"<<score<<endl;
    if (score>600&&score<=750)
    {
        cout<<"您考上了一本"<<endl;
        if (score>700)
        {
            cout<<"您考上了北大"<<endl;
        }
        else if (score>650)
        {
            cout<<"您考上了清华"<<endl;
        }
        else
        {
            cout<<"您考上了人大"<<endl;
        }
    }
    else if (score>500&&score<=600)
    {
        cout<<"您考上了二本"<<endl;
    }
    else if(score>400&&score<=500)
    {
        cout<<"您考上了三本"<<endl;
    }
    else
    {
        cout<<"未考上本科"<<endl;
    }
    system("pause");
    return 0;

    }

}
搜索更多相关主题的帖子: score 分数 cout 输入 循环 
2022-12-09 21:51
后卿
Rank: 4
来 自:网络
等 级:业余侠客
帖 子:297
专家分:295
注 册:2016-10-22
得分:0 
问题解决了,不止要加个whiletrue,还要把return 9去掉
2022-12-09 21:56
Rocket_Pro
Rank: 2
等 级:论坛游民
帖 子:12
专家分:10
注 册:2022-12-17
得分:0 
#include "touwenjian.h"
int main()
{
    while True{
        int score=0;
        cout<<"请输入您的分数"<<endl;
        cin>>score;
        if (score>750||score<0)
        {
            cout<<"成绩输入不正确"<<endl;
        }
        else
        {
        cout<<"您的分数为"<<score<<endl;
        if (score>600&&score<=750)
        {
            cout<<"您考上了一本"<<endl;
            if (score>700)
        {
            cout<<"您考上了北大"<<endl;
        }
            else if (score>650)
        {
            cout<<"您考上了清华"<<endl;
        }
        else
        {
            cout<<"您考上了人大"<<endl;
        }
            else if (score>500&&score<=600)
        {
            cout<<"您考上了二本"<<endl;
        }
    else if(score>400&&score<=500)
    {
        cout<<"您考上了三本"<<endl;
    }
    else
    {
        cout<<"未考上本科"<<endl;
    }
    system("pause");
    return 0;
    }
}
2022-12-21 14:57
mochu
Rank: 2
等 级:论坛游民
帖 子:5
专家分:10
注 册:2020-10-4
得分:0 
程序代码:
#include "touwenjian.h"
int main()
{
    while (true){
        int score=0;
        cout<<"请输入您的分数"<<endl;
        cin>>score;
        if (score>750||score<0)
        {
            cout<<"成绩输入不正确"<<endl;
        }
        else
        {
            cout<<"您的分数为"<<score<<endl;
            if (score>600&&score<=750)
            {
                cout<<"您考上了一本"<<endl;
                if (score>700)
                {
                    cout<<"您考上了北大"<<endl;
                }
                else if (score>650)
                {
                    cout<<"您考上了清华"<<endl;
                }
                else
                {
                    cout<<"您考上了人大"<<endl;
                }}
                else if (score>500&&score<=600)
                {
                    cout<<"您考上了二本"<<endl;
                }
                else if(score>400&&score<=500)
                {
                    cout<<"您考上了三本"<<endl;
                }
                else
                {
                    cout<<"未考上本科"<<endl;
                }}
        system("pause");
        system("cls");
                }
                system("pause");
                return 0;
            
        }
2022-12-23 16:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510911-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022278 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved