注册 登录
编程论坛 C++教室

哪个高手,能帮我编一个菜单用while循环的

维伟 发布于 2010-05-15 00:22, 422 次点击
谢谢
1 回复
#2
最近不在2010-05-17 17:15
程序代码:
// Note:Your choice is C++ IDE
#include <iostream>
using namespace std;

void help()
{
    cout<<"- - - 帮助信息 - - -"<<endl;
    cout<<"1:input"<<endl;      //具体功能可以自己写函数
    cout<<"2:output"<<endl;
    cout<<"3:clearscreen"<<endl;
    cout<<"4:helpinfo"<<endl;
    cout<<"5:exit"<<endl;
}
int main()
{
    system("color 2");
    help();
    while(1)
    {
        char c;
        cout<<'>';
        cin>>c;
   
        switch(c)
        {
            case '1':
            {
                cout<<"input"<<endl;
            }
            break;
            case '2':
            {
                cout<<"output"<<endl;
            }break;
            case '3':
            {
                system("cls");
            }
            break;
            case '4':
            {
                help();
            }
            break;
            case '5':
            {
                exit (0);
            }
            break;
            default:
            {
                cout<<"no such cmd!"<<endl;
            }
            break;
        }        
    }  
    return 0;
}
1