| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 947 人关注过本帖
标题:写了一个简单的学员系统.就是没有文件输入输出
只看楼主 加入收藏
新人学习
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:145
专家分:187
注 册:2017-10-26
结帖率:66.67%
收藏
 问题点数:0 回复次数:0 
写了一个简单的学员系统.就是没有文件输入输出
#include<iostream>
#include<string>
int I;
using namespace std;
struct Xue
{
    unsigned int bianhao;
    string name;
    unsigned int yuwen;
    unsigned int shuxue;
}xueyuan[100];

void caidan();
void caidan01();
char xuanze();
void fuzhi(Xue &);
void chazhao(string, Xue []);

int main()
{
    char ch;
    string zhao, shanchu;
    caidan();
    while ((ch = xuanze())<'a' || ch>'d')
    {
        cout << "输入错误!请输入有效选项:";
    }
    while (ch != 'e')
    {
        switch (ch)
        {
        case 'a':
            fuzhi(xueyuan[I]);
            break;
        case 'b':
            
            cout << "输入姓名:";
            cin >> zhao;
            chazhao(zhao, xueyuan);
            break;
        case 'c':
            
            int i;
            cout << "输入姓名:";
            cin >> shanchu;
            for (i = 0; i < I&&shanchu != xueyuan[i].name; i++)
            {
                continue;
            }
            if (shanchu == xueyuan[i].name)
            {
                while (i < I)
                {
                    xueyuan[i].bianhao = xueyuan[i + 1].bianhao;
                    xueyuan[i].name = xueyuan[i + 1].name;
                    xueyuan[i].yuwen = xueyuan[i + 1].yuwen;
                    xueyuan[i].shuxue = xueyuan[i + 1].shuxue;
                    i++;
                }
                I--;
            }
            else
                cout << "没有你查找的人:\n";
            break;
        case 'd':
            for (int j = 0; j < I; j++)
            {
                cout << xueyuan[j].bianhao << "  " << xueyuan[j].name << "  "
                    << xueyuan[j].yuwen << "  " << xueyuan[j].shuxue << endl;
            }
            break;
        }
        caidan();
        while ((ch = xuanze())<'a' || ch>'d')
        {
            cout << "输入错误!请输入有效选项:";
        }


    }
   

    system("pause");
    return 0;
}

void caidan()
{
    cout << "********************学生管理系统********************\n";
    cout << "a)增加学员, b)查找学员\n";
    cout << "c)删除学员, d)显示所有学员. e)退出\n";
    cout << "****************************************************\n选择:";
}

char xuanze()
{
    char c;
    cin >> c;
    while (cin.get() != '\n')
        continue;
    return c;

}

void fuzhi(Xue &xueyuan)
{
    cout << "输入学员编号:";
    while (!(cin >> xueyuan.bianhao))
    {
        cin.clear();
        cin.sync();
        cout << "乖~请正确输入:";
    }


    cout << "输入学员姓名:";
    cin.sync();
    cin >> xueyuan.name;
   
   
    cout << "输入语文成绩:";
    cin.sync();
    while (!(cin >> xueyuan.yuwen))
    {
        cin.clear();
        cin.sync();
        cout << "乖~请正确输入:";
    }
    cout << "输入数学成绩:";
    cin.sync();
    while (!(cin >> xueyuan.shuxue))
    {
        cin.clear();
        cin.sync();
        cout << "乖~请正确输入:";
    }
    cout << "**********学员属性**********\n";
    cout << "编号: " << xueyuan.bianhao << endl;
    cout << "name: " << xueyuan.name << endl;
    cout << "语文: " << xueyuan.yuwen << endl;
    cout << "数学: " << xueyuan.shuxue << endl;
    cout << "注册学员成功.\n";
    I++;

}

void caidan01()
{
    cout << "********************学生管理系统********************\n";
    cout << "a)修改编号, b)修改姓名\n";
    cout << "c)修改语文成绩, d)修改数学成绩,e)返回主菜单.\n";
    cout << "****************************************************\n选择:";
}

void chazhao(string chazhao, Xue yuan[])
{
    int i;
    char ch;
    for (i = 0; i < I&&chazhao != yuan[i].name; i++)
    {
        continue;
    }
    if (i == I)
    {
        cout << "查无此人!\n";
    }
    else
    {
        cout << "**********查找的学员属性**********\n";
        cout << "编号: " << yuan[i].bianhao << endl;
        cout << "name: " << yuan[i].name << endl;
        cout << "语文: " << yuan[i].yuwen << endl;
        cout << "数学: " << yuan[i].shuxue << endl;
        system("pause");
        caidan01();
        while ((ch = xuanze())<'a' || ch>'e')
        {
            cout << "输入错误!请输入有效选项:";
        }
        while (ch != 'e')
        {
            switch (ch)
            {
            case 'a':
                    cout << "输入编号:";
                    cin.sync();
                    while (!(cin >> yuan[i].bianhao))
                    {
                        cin.clear();
                        cin.sync();
                        cout << "乖~请正确输入:";
                    }
                    cout << "修改以后的编号是:" << yuan[i].bianhao << endl;
                    break;
            case 'b':
                cout << "输入姓名:";
                cin.sync();
                cin >> yuan[i].name;
                cout << "修改以后的姓名是:" << yuan[i].name << endl;
                break;
            case 'c':
                cout << "输入语文成绩:";
                cin.sync();
                while (!(cin >> yuan[i].yuwen))
                {
                    cin.clear();
                    cin.sync();
                    cout << "乖~请正确输入:";
                }
                cout << "修改以后的语文成绩是:" << yuan[i].yuwen << endl;
                break;
            case 'd':
                cout << "输入数学成绩:";
                cin.sync();
                while (!(cin >> yuan[i].shuxue))
                {
                    cin.clear();
                    cin.sync();
                    cout << "乖~请正确输入:";
                }
                cout << "修改以后的数学成绩是:" << yuan[i].shuxue << endl;
                break;

            }
            caidan01();
            while ((ch = xuanze())<'a' || ch>'e')
            {
                cout << "输入错误!请输入有效选项:";
            }

               


        }





    }

}
搜索更多相关主题的帖子: 输入 name while cout cin 
2018-01-01 22:11
快速回复:写了一个简单的学员系统.就是没有文件输入输出
数据加载中...
 
   



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

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