学生管理系统

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#include<iostream>
#include<vector>
#include<windows.h>
using namespace std;
int a=999;
int b=0;
bool c=false;
struct student{
    string name;
    int age;
    int card;
    int grade;
}s;
void ka(){
    cout<<"学生管理系统:"<<endl;
    cout<<"1.新建学生信息"<<endl;
    cout<<"2.查找学生信息"<<endl;
    cout<<"3.修改学生信息"<<endl;
    cout<<"4.删除学生信息"<<endl;
    cout<<"5.退出系统"<<endl;
}
vector<student> insert(vector<student> v){
    cout<<"请输入学生姓名:";
    cin>>s.name;
    cout<<"请输入学生年龄:";
    cin>>s.age;
    cout<<"请输入学生年级:";
    cin>>s.grade;
    cout<<"你的学号是:";
    a++;
    s.card=a;
    cout<<s.card;
    v.push_back(s);
    Sleep(500);
    return v;
}
vector<student> find(vector<student> v){
    while(1){
        cout<<"你要用什么形式查找:"<<endl;
        cout<<"1.学生卡号"<<endl;
        cout<<"2.学生年龄"<<endl;
        cout<<"3.学生姓名"<<endl;
        cout<<"4.退出"<<endl;
        cin>>b;
        if(b==4){
            break;
        }
        switch(b){
        case 1:{
            cin>>b;
            for(int i=0;i<v.size();i++){
                if(v[i].card==b){
                    cout<<"学生姓名:";
                    cout<<v[i].name<<endl;
                    cout<<"请输入学生年龄:";
                    cout<<v[i].age<<endl;
                    cout<<"请输入学生年级:";
                    cout<<v[i].grade<<endl;
                    Sleep(2000);
                    c=true;
                }
            }
        if(c==false){
            cout<<"没找到";
            Sleep(500);
        }
        break;
        }
         
         
        case 2:{
            cin>>b;
            for(int i=0;i<v.size();i++){
                if(v[i].age==b){
                    cout<<"学生姓名:";
                    cout<<v[i].name<<endl;
                    cout<<"请输入学生年龄:";
                    cout<<v[i].age<<endl;
                    cout<<"请输入学生年级:";
                    cout<<v[i].grade<<endl;
                    Sleep(2000);
                    c=true;
                    }
                }
            if(c==false){
                cout<<"没找到";
                Sleep(500);        
                }
            break;
            }
        case 3:{
        string d;
        cin>>d;
        for(int i=0;i<v.size();i++){
            if(v[i].name.find(d)!=string::npos){
                cout<<"学生姓名:";
                cout<<v[i].name<<endl;
                cout<<"请输入学生年龄:";
                cout<<v[i].age<<endl;
                cout<<"请输入学生年级:";
                cout<<v[i].grade<<endl;
                Sleep(2000);
                c=true;
            }
        }
        if(c==false){
            cout<<"没找到";
            Sleep(500);
        }
        break;
        }
          
        default :{
          
        break;
        }
        }
        system("cls");
}
  
    return v;
}
vector<student> change(vector<student> v){
    for(int i=0;i<v.size();i++){
        if(v[i].card==b){
        while(1){
            c=true;
            cout<<"你要修改什么:"<<endl;
            cout<<"1.学生姓名"<<endl;
            cout<<"2.学生年龄"<<endl;
            cout<<"3.学生年级"<<endl;
            cout<<"4.退出"<<endl;
            cin>>b;
            if(b==4){
                break;
            }
        switch(b){
            case 1:{
                cout<<v[i].name<<endl;
                cin>>v[i].name;
                break;
            }
            case 2:{
                cout<<v[i].age<<endl;
                cin>>v[i].age;
                break;
            }
            case 3:{
                cout<<v[i].grade<<endl;
                cin>>v[i].grade;
                break;
            }
        default:{
             
             
        break;
        }
        }
        system("cls");
        }
      
    }
    }
    if(c==false){
        cout<<"没找到";
        Sleep(500);
    }
      
      
    return v;
}
int main(){
    vector<student> v;
    while(1){
        ka();
        int n;
        cin>>n;
        if(n==5){
            break;
        }
    switch(n){
        case 1:{
            v=insert(v);
            break;
        }
        case 2:{
            find(v);
            break;
        }
        case 3:{
            cout<<"请输入学生卡号:";
            cin>>b;
            change(v);
            break;
        }
        case 4:{
            break;
        }
    }
        system("cls");
    }
      
    return 0;
  
}

  

posted @   昵称就是最好的昵称  阅读(15)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗
点击右上角即可分享
微信分享提示