栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

学生管理系统(全代码)(DEV-C++)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

学生管理系统(全代码)(DEV-C++)

#include
#include
#include
#include
using namespace std;
void caidan();
class student{
    public:
    int xh;
    string name;
    int yuwen;
    int shuxue;
    int yingyu;     
    void set(int xh1,string name1,int yuwen1,int shuxue1,int yingyu1){
        xh = xh1;
        name = name1;
        yuwen = yuwen1;
        shuxue = shuxue1;
        yingyu = yingyu1;
    }
    void get(){
        cout<<"学号:"<         cout<<"语文:"<         cout<<"数学:"<         cout<<"英语:"<     }
};
student a[100];
int id=0;
void add(int id1){
    cout<<"请输入学生的学号"<     int q;
    cin>>q;
    for(int i=0;i<100;i++){
        if(a[i].xh==q){
            cout<<"已有该学号"<             add(id1);
            break;
        }
}
    a[id1].xh=q;
    cout<<"请输入学生的姓名"<     string d;
    cin>>d;
    a[id1].name=d;
    cout<<"请输入学生的语文成绩"<     int dd;
    cin>>dd;
    a[id1].yuwen=dd;
    cout<<"请输入学生的数学成绩"<     int ddd;
    cin>>ddd;
    a[id1].shuxue=ddd;
    cout<<"请输入学生的英语成绩"<     int dddd;
    cin>>dddd;
    a[id1].yingyu=dddd;
    id++;
    cout<<"添加成功"<     caidan(); 
}

void search(){
    cout<<"请输入学号"<     int xh2;
    cin>>xh2;
    for(int i=0;i<100;i++){
        if(a[i].xh==xh2){
            a[i].get();
            break;
        }
        else{
            cout<<"没有该学生"<             break;
        } 
    }
    
}
void change(){
    cout<<"请输入学生的学号"<     int xh3;
    cin>>xh3;
    for(int i=0;i<100;i++){
        if(a[i].xh==xh3){
            a[i].get();
        }
        cout<<"请马上开始改变"<         cout<<"语文:"; 
        cin>>a[i].yuwen;
        cout<<"数学:"; 
        cin>>a[i].shuxue;
        cout<<"英语:"; 
        cin>>a[i].yingyu;
        break;
    }
    caidan(); 
} 
void dele(){
    cout<<"请输入删除学生的学号"<     int xh4;
    cin>>xh4;
    for(int i=0;i<100;i++){
        if(a[i].xh==xh4){
            a[i].xh=0; 
            break;
        }
    }
    cout<<"已丢入垃圾桶"<     caidan();
}
void save(){
    ofstream outt("./student.txt",ios::app);
    if(outt==NULL){
        cout<<"打开txt文件失败!n";
    }
    else{
        for(int i=0;i<100;i++){
            if(a[i].xh!=0)
                outt<         }
    }
    outt.close();
    cout<<"保存成功!"<     caidan();
}
void load(){
    ifstream in1("./student.txt",ios::in);
    if(in1==NULL){
        cout<<"打开txt文件失败!n";
    }
    else{
        int i=0;
        while(!in1.eof()){
                in1>>a[i].xh>>a[i].name>>a[i].yuwen>>a[i].shuxue>>a[i].yingyu;
            i++; 
        }
        }
        
    
    cout<<"读取成功!"<     in1.close();
    caidan();
}
void caidan(){
    cout<<"**********请输入您需要的操作**********"<     cout<<"**********  1.增加学生      **********"<     cout<<"**********  2.删除学生      **********"<     cout<<"**********  3.修改学生信息  **********"<     cout<<"**********  4.查找学生信息  **********"<     cout<<"**********  5.保存学生信息  **********"<     cout<<"**********  6.加载学生信息  **********"<     int i;
    cin>>i;
    switch(i){
        case 1:
            add(id);break;
        case 2:
            dele();break;
        case 3:
            change();break;
        case 4:
            search();break;
        case 5:
            save();break;
        case 6:
            load();break;
    }
}
int main(){
    caidan();         
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/983602.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号