首页 > 其他分享 >饭卡(容器)3.0

饭卡(容器)3.0

时间:2023-12-29 20:12:57浏览次数:32  
标签:case 容器 饭卡 cout int number break vector 3.0

#include <iostream>
#include <vector>
using namespace std;
#define list 1000
struct a{
    string name;
    int id;
    int age;
    string Class;
}index;
void MAIN(){
    cout<<"欢迎使用学生管理系统"<<endl
        <<"1.新建学生信息"<<endl
        <<"2.查找学生信息"<<endl
        <<"3.修改学生信息"<<endl
        <<"4.删除学生信息"<<endl
        <<"5.退出管理系统"<<endl;
}
void FMAIN(){
    cout<<"请选择您要查找的方式:"<<endl
        <<"1.根据学号查找"<<endl
        <<"2.根据姓名查找"<<endl
        <<"3.根据年龄查找"<<endl
        <<"4.根据班级查找"<<endl
        <<"5.返回主界面"<<endl;
}
void FFMAIN(string n){
    cout<<"请选择您要"<<n<<"的方式:"<<endl
        <<"1.根据学号"<<n<<endl
        <<"2.返回"<<n<<endl;
}
vector<a> no1(vector<a> x,int number);
vector<a> no2(vector<a> x,int number);
vector<a> no3(vector<a> x,int number);
vector<a> no4(vector<a> x,int number);
int main(){
    vector<a>x;
    int n,number = 0;
    while(1){
        MAIN();
        cin>>n;
        if(n>5){
            system("cls");
            continue;
        }else if(n==5){
            system("pause");
            break;
        }
        switch(n){
            case 1:
                x = no1(x,number);
                number++;
                break;
#include <iostream>
#include <vector>
using namespace std;
#define list 1000
struct a{
    string name;
    int id;
    int age;
    string Class;
}index;
void MAIN(){
    cout<<"欢迎使用学生管理系统"<<endl
        <<"1.新建学生信息"<<endl
        <<"2.查找学生信息"<<endl
        <<"3.修改学生信息"<<endl
        <<"4.删除学生信息"<<endl
        <<"5.退出管理系统"<<endl;
}
void FMAIN(){
    cout<<"请选择您要查找的方式:"<<endl
        <<"1.根据学号查找"<<endl
        <<"2.根据姓名查找"<<endl
        <<"3.根据年龄查找"<<endl
        <<"4.根据班级查找"<<endl
        <<"5.返回主界面"<<endl;
}
void FFMAIN(string n){
    cout<<"请选择您要"<<n<<"的方式:"<<endl
        <<"1.根据学号"<<n<<endl
        <<"2.返回"<<n<<endl;
}
vector<a> no1(vector<a> x,int number);
vector<a> no2(vector<a> x,int number);
vector<a> no3(vector<a> x,int number);
vector<a> no4(vector<a> x,int number);
int main(){
    vector<a>x;
    int n,number = 0;
    while(1){
        MAIN();
        cin>>n;
        if(n>5){
            system("cls");
            continue;
        }else if(n==5){
            system("pause");
            break;
        }
        switch(n){
            case 1:
                x = no1(x,number);
                number++;
                break;
            case 2:
                x = no2(x,number);
                break;
            case 3:
                x = no3(x,number);
                break;
            case 4:
                x = no4(x,number);
                break;
            case 5:
                system("pause");
                return 0;
        }
        system("pause");
        system("cls");
    }
    return 0;
}
vector<a> no1(vector<a> x,int number){
    cout<<"请输入你的姓名:";
    cin>>index.name;
    cout<<"请输入你的年龄:";
    cin>>index.age;
    cout<<"请输入你的班级:";
    cin>>index.Class;
    index.id = list+number;
    cout<<"你的学号是:"<<index.id<<endl;
    x.push_back(index);
    return x;
}
vector<a> no2(vector<a> x,int number){
    int n;
    while(1){
        system("cls");
        FMAIN();
        cin>>n;
        if(n==5){
            break;
        }
        int _id,_age;
        string _name,_class;
        bool have = false;
        switch(n){
            case 1:{
                cout<<"请输入你的学号:";
                cin>>_id;
                for(int i = 0;i<x.size();i++){
                    /*if(x[i].id==-1){
                        cout<<"无法找到该学生信息"<<endl;
                        return x;*/
                    /*}else */
                    if(_id==x[i].id){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl; 
                        have = true;
                    }
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
            case 2:{
                cout<<"请输入你的姓名:";
                cin>>_name;
                for(int i = 0;i<x.size();i++){
                    if(_name==x[i].name || x[i].name.find(_name)!=string::npos){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl;
                        cout<<"学号:"<<x[i].id<<endl;
                        cout<<endl;
                        have = true;
                    }
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
            case 3:{
                cout<<"请输入你的年龄:";
                cin>>_age;
                for(int i = 0;i<x.size();i++){
                    if(_age==x[i].age){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl;
                        cout<<"学号:"<<x[i].id<<endl;
                        cout<<endl;
                        have = true;
                    }    
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
            case 4:{
                cout<<"请输入你的班级:";
                cin>>_class;
                for(int i = 0;i<x.size();i++){
                    if(_class==x[i].Class){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl;
                        cout<<"学号:"<<x[i].id<<endl;
                        cout<<endl;
                        have = true;
                    }    
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
        }
        system("pause");
    }
    return x;
}
vector<a> no3(vector<a> x,int number){
    int n;
    while(1){
        system("cls");
        FFMAIN("修改");
        cin>>n;
        if(n==2){
            break;
        }
        int _id,_age,_class;
        string _name;
        bool have = false;
        switch(n){
            case 1:
                cout<<"请输入你的学号:";
                cin>>_id;
                for(int i = 0;i<number;i++){
                    if(list+i==_id){
                        system("cls"); 
                        cout<<"请选择你要修改的信息"<<endl
                            <<"*****1.修改姓名*****"<<endl
                            <<"*****2.修改年龄*****"<<endl
                            <<"*****3.修改班级*****"<<endl
                            <<"*****4.返回*********"<<endl;
                        int _n;
                        cin>>_n;
                        switch(n){
                            case 1:{
                                cout<<"请输入你要修改的姓名:";
                                cin>>_name;
                                x[i].name = _name; 
                                break;
                            }
                            case 2:{
                                cout<<"请输入你要修改的年龄:";
                                cin>>_age;
                                x[i].name = _age; 
                                break;
                            }
                            case 3:{
                                cout<<"请输入你要修改的班级:";
                                cin>>_class;
                                x[i].name = _class; 
                                break;
                            }
                            case 4:{
                                break;
                            }
                        }
                        have = true;   
                    }    
                }
                if(!have){
                    cout<<"修改失败"<<endl;
                    break;
                }
                cout<<"修改成功"<<endl;
                break;
            }
        system("pause");
    }
    return x;
}
vector<a> no4(vector<a> x,int number){
    int _id;
    cout<<"请输入你的学号:";
    cin>>_id;
    bool have = false;
    for(int i = 0;i<number;i++){
        if(_id==x[i].id){
            x.erase(x.begin()+i);
            //x[i].id = -1;
            have = true;
        }
    }
    if(!have){
        cout<<"删除失败"<<endl;
        return x;
    }
    cout<<"删除成功"<<endl;
    return x;
}

 

case 2:
                x = no2(x,number);
                break;
            case 3:
                x = no3(x,number);
                break;
            case 4:
                x = no4(x,number);
                break;
            case 5:
                system("pause");
                return 0;
        }
        system("pause");
        system("cls");
    }
    return 0;
}
vector<a> no1(vector<a> x,int number){
    cout<<"请输入你的姓名:";
    cin>>index.name;
    cout<<"请输入你的年龄:";
    cin>>index.age;
    cout<<"请输入你的班级:";
    cin>>index.Class;
    index.id = list+number;
    cout<<"你的学号是:"<<index.id<<endl;
    x.push_back(index);
    return x;
}
vector<a> no2(vector<a> x,int number){
    int n;
    while(1){
        system("cls");
        FMAIN();
        cin>>n;
        if(n==5){
            break;
        }
        int _id,_age;
        string _name,_class;
        bool have = false;
        switch(n){
            case 1:{
                cout<<"请输入你的学号:";
                cin>>_id;
                for(int i = 0;i<x.size();i++){
                    /*if(x[i].id==-1){
                        cout<<"无法找到该学生信息"<<endl;
                        return x;*/
                    /*}else */
                    if(_id==x[i].id){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl; 
                        have = true;
                    }
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
            case 2:{
                cout<<"请输入你的姓名:";
                cin>>_name;
                for(int i = 0;i<x.size();i++){
                    if(_name==x[i].name || x[i].name.find(_name)!=string::npos){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl;
                        cout<<"学号:"<<x[i].id<<endl;
                        cout<<endl;
                        have = true;
                    }
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
            case 3:{
                cout<<"请输入你的年龄:";
                cin>>_age;
                for(int i = 0;i<x.size();i++){
                    if(_age==x[i].age){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl;
                        cout<<"学号:"<<x[i].id<<endl;
                        cout<<endl;
                        have = true;
                    }    
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
            case 4:{
                cout<<"请输入你的班级:";
                cin>>_class;
                for(int i = 0;i<x.size();i++){
                    if(_class==x[i].Class){
                        cout<<"姓名:"<<x[i].name<<endl;
                        cout<<"年龄:"<<x[i].age<<endl;
                        cout<<"班级:"<<x[i].Class<<endl;
                        cout<<"学号:"<<x[i].id<<endl;
                        cout<<endl;
                        have = true;
                    }    
                }
                if(!have){
                    cout<<"查找失败"<<endl;
                }
                break;
            }
        }
        system("pause");
    }
    return x;
}
vector<a> no3(vector<a> x,int number){
    int n;
    while(1){
        system("cls");
        FFMAIN("修改");
        cin>>n;
        if(n==2){
            break;
        }
        int _id,_age,_class;
        string _name;
        bool have = false;
        switch(n){
            case 1:
                cout<<"请输入你的学号:";
                cin>>_id;
                for(int i = 0;i<number;i++){
                    if(list+i==_id){
                        system("cls"); 
                        cout<<"请选择你要修改的信息"<<endl
                            <<"*****1.修改姓名*****"<<endl
                            <<"*****2.修改年龄*****"<<endl
                            <<"*****3.修改班级*****"<<endl
                            <<"*****4.返回*********"<<endl;
                        int _n;
                        cin>>_n;
                        switch(n){
                            case 1:{
                                cout<<"请输入你要修改的姓名:";
                                cin>>_name;
                                x[i].name = _name; 
                                break;
                            }
                            case 2:{
                                cout<<"请输入你要修改的年龄:";
                                cin>>_age;
                                x[i].name = _age; 
                                break;
                            }
                            case 3:{
                                cout<<"请输入你要修改的班级:";
                                cin>>_class;
                                x[i].name = _class; 
                                break;
                            }
                            case 4:{
                                break;
                            }
                        }
                        have = true;   
                    }    
                }
                if(!have){
                    cout<<"修改失败"<<endl;
                    break;
                }
                cout<<"修改成功"<<endl;
                break;
            }
        system("pause");
    }
    return x;
}
vector<a> no4(vector<a> x,int number){
    int _id;
    cout<<"请输入你的学号:";
    cin>>_id;
    bool have = false;
    for(int i = 0;i<number;i++){
        if(_id==x[i].id){
            x.erase(x.begin()+i);
            //x[i].id = -1;
            have = true;
        }
    }
    if(!have){
        cout<<"删除失败"<<endl;
        return x;
    }
    cout<<"删除成功"<<endl;
    return x;
}

 

标签:case,容器,饭卡,cout,int,number,break,vector,3.0
From: https://www.cnblogs.com/w6826301/p/17935614.html

相关文章

  • 饭卡(容器)2.0
    #include<iostream>#include<vector>#include<windows.h>usingnamespacestd;inta=999;intb=0;boolc=false;structstudent{stringname;intage;intcard;intgrade;}s;voidka(){cout......
  • APISIX 3.0安装及配置使用【转】
    最近一直在研究微服务相关内容,通过对比各大API网关,发现新起之秀APISIX无论从开源程度上来讲还是功能上,都拥有很大的优势。经历了几天折磨一样的学习,目前在本地环境中配置成功了一套,以供自己留存吧,实在是网上的很多文章要么太老了,要么就是乱写一通。 APISIX官方网址:https://ap......
  • 容器开源情况
             ......
  • Citrix ADC Release 13.0 Build 92.18 发布 - 混合多云应用交付控制器
    CitrixADCRelease13.0Build92.18发布-混合多云应用交付控制器CitrixADCRelease13.0Build92.18(nCore,VPX,SDX,CPX,BLX)CitrixADC-混合多云应用交付控制器作者主页:sysin.org大规模应用程序交付可能很复杂。使用NetScaler让一切变得更简单。产品概述CitrixAD......
  • 【HarmonyOS】如何获取屏幕宽高&父容器的宽高
    【关键字】HarmonyOS、屏幕宽高、父容器宽高、组件通用信息、组件标识1、写在前面在鸿蒙应用开发的过程中,需要用到屏幕的宽高,那么我们该如何获取手机屏幕的宽度和高度呢?另外,某个组件的父容器的宽高我们能不能获取到呢?带着这些问题,通过查找相关资料,结合实际的代码进行测试,顺利的获取......
  • C++常用的无序的关联容器
    常用的无序关联容器在实际问题场景中,除了常见的线性表结构,字符串,排序操作之外,散列表和红黑树也是非常常见的,有很多应用场景都会用到它们。散列表虽然比较占空间,但是它的增删查的都很快,趋近于O(1);红黑树也是一颗二叉排序树,所以入红黑树的数据都是经过排序的,它的增删查时间复杂度都是......
  • Ubuntu23.04下anaconda3的安装、配置
    一.安装anaconda3前往清华园镜像下载anaconda3的安装包https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D选择最新镜像Anaconda3-2023.09-0-Linux-x86_64.sh 安装1bashAnaconda3[version].shversion是下载的包的版本,如:bash Anaconda3-2023.09-0-L......
  • spark 3.0新特性
    一、AdaptiveQueryExecution自适应查询https://blog.51cto.com/u_12865/7338853 二、DynamicPartionPruning动态裁剪分区ApacheSpark3.0动态分区裁剪(DynamicPartitionPruning)介绍https://www.iteblog.com/archives/8589.htmlApacheSpark3.0动态分区裁剪(Dynam......
  • PTS 3.0:可观测加持的下一代性能测试服务
    作者:肖长军(穹谷)大家好,我是来自阿里云云原生应用平台的肖长军,花名穹谷,我此次分享的主题是《可观测加持的下一代性能测试服务》。提到性能测试大家并不陌生,性能测试已成为评估系统能力、识别系统弱点、进行系统调优,验证系统稳定性等的重要手段。我们一般进行性能测试的大概流程就是构......
  • PTS 3.0:可观测加持的下一代性能测试服务
    作者:肖长军(穹谷)大家好,我是来自阿里云云原生应用平台的肖长军,花名穹谷,我此次分享的主题是《可观测加持的下一代性能测试服务》。提到性能测试大家并不陌生,性能测试已成为评估系统能力、识别系统弱点、进行系统调优,验证系统稳定性等的重要手段。我们一般进行性能测试的大概流程就......