C++课程设计-成绩管理系统

提供了一个用于管理学生信息、成绩、以及操作的系统,包括增加、删除、修改、查询学生信息,成绩排序,以及查看所有信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//C++课程设计 
//成绩管理系统 
//第一次运行请先增加学生信息,一遍创建文件,保存数据 
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<fstream>
#include<windows.h>
#include<conio.h>
#define ESC 27
#define SPACE 32
#define IPGROUND_INTENSITY 40
using namespace std;
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int rank_[101];
double score[101];
int flag = 0;
//=============================================
//定义一个学生类
struct Student
{
    char name[20];
    int num;
    double Cscore;
    double Mscore;
    double Escore;
}stu[101];//定义对象数组
//=============================================
void showall()
{   system("cls");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("\n\t\t\t   ※※※※※※※※\n");
    printf("\t\t\t   ※");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
    printf("查看所有信息");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("※\n\t\t\t   ※※※※※※※※\n");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
    printf("\n\t\t   ※※※※※※※※※※※※※※※※※\n");
    printf("\t\t   ※ 姓名  学号  高数  英语  离散 ※\n");
    fstream all("StuMessage.txt",ios::in|ios::binary);
    if(!all)
    {
        cerr<<"文件打开失败!"<<endl;
        abort();
    }
    all.seekg(0,ios::beg);
    for(int i=1;i<101;i++)
    {
        all.read((char *)&stu[i],sizeof(stu[i]));
        if(stu[i].num)
        {
            printf("\t\t   ※ ");
            cout<< stu[i].name<<"   "<<stu[i].num<<"    "<<stu[i].Mscore<<"    "<<stu[i].Escore<<"    "<<stu[i].Cscore<<"  ※\n";
        }
    }
    all.close();
    printf("\t\t   ※※※※※※※※※※※※※※※※※\n");
    printf("\n请按ESC返回主菜单\n");
    char s;
    s = getch();
    if(s == ESC);
}
void showall_()
{
    printf("\n\t\t   ※※※※※※※※※※※※※※※※※");
    if(flag) printf("※※※※※");
    printf("\n");
    printf("\t\t   ※ 姓名  学号  高数  英语  离散 ");
    if(flag) printf("总分  排名");
    printf("※\n");
    fstream all("StuMessage.txt",ios::in|ios::binary);
    if(!all)
    {
        cerr<<"文件打开失败!"<<endl;
        abort();
    }
    all.seekg(0,ios::beg);//找到文件头
    for(int i=1;i<101;i++)
    {
        all.read((char *)&stu[i],sizeof(stu[i]));
        if(stu[i].num)
        {
            printf("\t\t   ※ ");
            cout << stu[i].name<<"   "<<stu[i].num<<"    "<<stu[i].Mscore<<"    "<<stu[i].Escore<<"    "<<stu[i].Cscore;
            if(flag) cout << "   " << score[i] << "   " << rank_[i];
            cout <<"  ※\n";
        }
    }
    all.close();
    printf("\t\t   ※※※※※※※※※※※※※※※※※");
    if(flag) printf("※※※※※");
    printf("\n");
}
//=============================================
void show()
{
	//改变字体颜色==============================================================
	SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
	printf("                ╲          ☆成绩の管理☆         ╱\n");
	printf("                  ╲       ★    系统    ★      ╱  \n");//←↑→↓
	printf("                    ╲    ★    System    ★   ╱    \n");
	printf("                      ╲ ★                ★╱      \n");
	printf("\t\t   ※※※※※※※※※※※※※※※※\n");
	printf("\t\t   ※                            ※\n");
	printf("\t\t   ※                            ※\n");
	printf("\t\t   ※         主菜单             ※\n");
	printf("\t\t   ※     1.增加学生信息         ※\n");
	printf("\t\t   ※     2.删除学生信息         ※\n");
	printf("\t\t   ※     3.修改学生信息         ※\n");
	printf("\t\t   ※     4.查询学生信息         ※\n");
	printf("\t\t   ※     5.查看所有信息         ※\n");
	printf("\t\t   ※     Esc.退出成绩管理系统   ※\n");
	printf("\t\t   ※                            ※\n");
	printf("\t\t   ※                            ※\n");
	printf("\t\t   ※※※※※※※※※※※※※※※※\n");
    printf("                      ╱       关于软件       ╲      \n");
	printf("                    ╱   学生成绩管理系统 1.0版 ╲    \n");
	printf("                  ╱       版权所有  陈涛制作     ╲  \n");
	printf("                ╱                                  ╲\n");
 	SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
//=============================================
int add_()
{
    system("cls");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("\n\t\t\t   ※※※※※※※※\n");
    printf("\t\t\t   ※");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
    printf("增加学生信息");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("※\n\t\t\t   ※※※※※※※※\n");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
    for(int i = 1; i < 101; i++)
    {printf("请按顺序添加学生的信息:\n");
    printf("姓名:");
    cin >> stu[i].name;//输入姓名
    printf("学号:");
    cin >> stu[i].num;//输入学号
    printf("高数成绩:");
    cin >> stu[i].Mscore;//输入高数成绩
    printf("英语成绩:");
    cin >> stu[i].Escore;//输入英语成绩
    printf("离散成绩:");
    cin >> stu[i].Cscore;//输入离散成绩
    printf("按ESC键退出,按任意键继续添加!\n");
    fstream addfile("StuMessage.txt",ios::in|ios::out|ios::binary);//以二进制方式打开文件
    if(!addfile)
    {cerr << "Open file error!" << endl;
    abort();}
    addfile.seekp(0,ios::end);//找到文件末尾
    addfile.write((char *)&stu[i],sizeof(stu[i]));//将数据写入文件中
    addfile.close();//关闭文件
    char a;a = getch();//定义一个字符变量,保存输入的命令
    if(a == ESC) return 1;//退出添加
    else continue;}//继续添加
}
//=============================================
int delete_()
{
    system("cls");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("\n\t\t\t   ※※※※※※※※\n");
    printf("\t\t\t   ※");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
    printf("删除学生信息");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("※\n\t\t\t   ※※※※※※※※\n");
    while(true)
    {
        flag = 0;
        showall_();
        int num, temp = -1;int k = 1;
        printf("请输入要删除学生的学号:");
        cin >> num;
        ifstream all("StuMessage.txt",ios::in|ios::out|ios::binary);
        if(!all)
        {
            cerr<<"文件打开失败!"<<endl;
            abort();
        }
        all.seekg(0,ios::beg);
        for(int i=0;i<101;i++)
        {
            all.read((char *)&stu[i],sizeof(stu[i]));
            if(stu[i].num == num)
                {k=0;temp = i;break;}
        }
        all.close();
        if(k)
        {
            cout << "查无此人!" << endl;
            printf("按任意键继续删除,按ESC返回主菜单\n");
            char c;
            c = getch();
            if(c == ESC)
            return 1;
            else continue;
        }
        if(temp==-1) continue;
        cout<<"确定删除"<<stu[temp].name<<"么y/n?"<< endl;
        char d;
        d = getch();
        if(d == 'y')
        {
            ofstream de("StuMessage.txt",ios::in|ios::out|ios::binary);
            if(!de)
            {
                cerr<<"文件打开失败!"<<endl;
                abort();
            }
            stu[temp].name[0] = '0';
            stu[temp].num = 0;
            stu[temp].Cscore = 0;
            stu[temp].Escore = 0;
            stu[temp].Mscore = 0;
            de.seekp(temp*sizeof(stu[temp]),ios::beg);
            de.write((char *)&stu[temp],sizeof(stu[temp]));
            de.close();
            cout << "删除成功" << endl;
        }
        else if(d == 'n') return 1;
        printf("按任意键继续删除,按ESC返回主菜单\n");
        char c;
        c = getch();
        if(c == ESC)
            return 1;
        else continue;
    }
}
//=============================================
int revise_()
{
    system("cls");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("\n\t\t\t   ※※※※※※※※\n");
    printf("\t\t\t   ※");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
    printf("修改学生信息");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("※\n\t\t\t   ※※※※※※※※\n");
    while(true)
    {
        flag = 0;
        showall_();
        int num, temp = -1;
        printf("请输入要修改学生的学号:");
        cin >> num;
        ifstream all("StuMessage.txt",ios::in|ios::out|ios::binary);
        if(!all)
        {
            cerr<<"文件打开失败!"<<endl;
            abort();
        }
        all.seekg(0,ios::beg);
        int k = 1;
        for(int i=0;i<101;i++)
        {
            all.read((char *)&stu[i],sizeof(stu[i]));
            if(stu[i].num == num)
                {k=0;//标记为找到了
                temp = i;break;}
        }//找到要修改的人
        if(k)
        {
            cout << "查无此人!" << endl;
            printf("按任意键继续删除,按ESC返回主菜单\n");
            char c;
            c = getch();
            if(c == ESC)
            return 1;
            else continue;
        }
        if(temp==-1) continue;
        all.close();
        ofstream de("StuMessage.txt",ios::in|ios::out|ios::binary);
        if(!de)
        {
            cerr<<"文件打开失败!"<<endl;
            abort();
        }
        char name[20];
        double Cscore, Mscore, Escore;
        printf("请按顺序输入要修改的学生信息:\n");
        printf("姓名:");
        cin >> name;
        printf("学号:");
        cin >> num;
        printf("高数成绩:");
        cin >> Mscore;
        printf("英语成绩:");
        cin >> Escore;
        printf("离散成绩:");
        cin >> Cscore;
        strcpy(stu[temp].name,name);
        stu[temp].num = num;
        stu[temp].Cscore = Cscore;
        stu[temp].Escore = Escore;
        stu[temp].Mscore = Mscore;
        de.seekp(temp*sizeof(stu[temp]),ios::beg);
        de.write((char *)&stu[temp],sizeof(stu[temp]));
        de.close();
        cout << "修改成功" << endl;
        printf("按任意键继续修改,按ESC返回主菜单\n");
        char c;
        c = getch();
        if(c == ESC)
            return 1;
        else continue;
    }
}
//=============================================
int seek_()
{
    system("cls");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("\n\t\t\t   ※※※※※※※※\n");
    printf("\t\t\t   ※");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
    printf("查找学生信息");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("※\n\t\t\t   ※※※※※※※※\n");
    while(true)
    {
        printf("按1以姓名查找\n");
        printf("按2以学号查找\n");
        char s;int k;
        s = getch();
        if(s == '1')
        {
            cout << "请输入要查找的学生的姓名:";
            string name;
            cin >> name;
            fstream iofile("StuMessage.txt",ios::in|ios::binary);
            if(! iofile)
            {
                cerr<<"文件打开失败!"<<endl;
                abort();
            }
            iofile.seekg(0,ios::beg);
            for(int i=0;i<101;i++)
            {
                k = 1;
                iofile.read((char *)&stu[i],sizeof(stu[i]));
                if(name==stu[i].name)
                {
                    k = 0;
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
                    cout << "您要查找的学生信息如下显示:" << endl;
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                    cout << "姓名:" << stu[i].name << endl;
                    cout << "学号:" << stu[i].num << endl;
                    cout << "高数成绩:" << stu[i].Mscore << endl;
                    cout << "英语成绩:" << stu[i].Escore << endl;
                    cout << "离散成绩:" << stu[i].Cscore << endl;
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
                    break;
                }
            }
            iofile.close();
            if(k)
            {
                cout << "查无此人!" << endl;
                printf("按任意键继续删除,按ESC返回主菜单\n");
                char c;
                c = getch();
                if(c == ESC)
                return 1;
                else continue;
            }
        }
        if(s == '2')
        {
            cout << "请输入要查找的学生的学号:";
            int num;
            cin >> num;
            fstream file("StuMessage.txt",ios::in|ios::binary);
            if(! file)
            {
                cerr<<"文件打开失败!"<<endl;
                abort();
            }
            file.seekg(0,ios::beg);
            for(int i=0;i<101;i++)
            {
                k = 1;
                file.read((char *)&stu[i],sizeof(stu[i]));
                if(num == stu[i].num)
                {
                    k = 0;
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
                    cout << "您要查找的学生信息如下显示:" << endl;
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
                    cout << "姓名:" << stu[i].name << endl;
                    cout << "学号:" << stu[i].num << endl;
                    cout << "高数成绩:" << stu[i].Mscore << endl;
                    cout << "英语成绩:" << stu[i].Escore << endl;
                    cout << "离散成绩:" << stu[i].Cscore << endl;
                    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
                    break;
                }
            }
            file.close();
            if(k)
            {
                cout << "查无此人!" << endl;
                printf("按任意键继续删除,按ESC返回主菜单\n");
                char c;
                c = getch();
                if(c == ESC)
                return 1;
                else continue;
            }
        }
        printf("按任意键继续查询,按ESC退出查找学生信息\n");
        char c;
        c = getch();
        if(c == ESC)
            return 1;
        else continue;
    }
}
//=============================================
void sort_()
{
    system("cls");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("\n\t\t\t   ※※※※※※※※\n");
    printf("\t\t\t   ※");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
    printf("学生成绩排序");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
    printf("※\n\t\t\t   ※※※※※※※※\n");
    SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
    memset(rank_,0,sizeof(rank_));
    memset(score,0,sizeof(score));
    int k = 0;
    fstream all("StuMessage.txt",ios::in|ios::binary);
    if(!all)
    {
        cerr<<"文件打开失败!"<<endl;
        abort();
    }
    all.seekg(0,ios::beg);
    for(int i=1;i<101;i++)
    {
        all.read((char *)&stu[i],sizeof(stu[i]));
        if(stu[i].num)
        {
            k++;
            score[i] = stu[i].Cscore + stu[i].Escore + stu[i].Mscore;
        }
    }
    all.close();
    for(int i = 1; i < 101; i++)
    {
        for(int  j = 1; j < 101-i; j++)
            if(score[j] < score[j+1])
            {
                double t;
                t = score[j];
                score[j] = score[j+1];
                score[j+1] = t;
                Student s;
                s = stu[j];
                stu[j] = stu[j+1];
                stu[j+1] = s;
            }
    }
    fstream iofile("StuMessage.txt",ios::in|ios::binary);
    if(! iofile)
    {
        cerr<<"文件打开失败!"<<endl;
        exit(1);
    }
    for(int i = 1;i <= k;i++)     //把5个初值写入文件
    {
        rank_[i] = i;
        iofile.write((char *)&stu[i],sizeof(stu[i]));
    }
    iofile.close();
    flag = 1;
    cout << "\n\n\n\n\n\t\t\t正在排序,请稍后……" << endl;
    Sleep(2000);
    cout << "\t\t\t排序完成!" << endl;
    showall_();
    printf("\n请按ESC返回主菜单\n");
    char d;
    d = getch();
    if(d == ESC);
}
//=============================================
int main()
{
    SMALL_RECT winPon={0,0,67,28};
	HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
	COORD buf={26,11};
	SetConsoleWindowInfo(con,2,&winPon);
	SetConsoleScreenBufferSize(con,buf);
	//输出标题==================================================================
	SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
	printf("\t※※※※※※※※※※※※※※※※※※※※※※※※※※\n");
	printf("\t※\t\t\t\t\t\t  ※\n");
	printf("\t※\t\t欢迎进入成绩管理系统\t\t  ※\n");
	printf("\t※\t\t\t\t\t\t  ※\n");
	printf("\t※※※※※※※※※※※※※※※※※※※※※※※※※※\n");
	show();
	while(true)
    {
        char c;
        c = getch();
        if(c == ESC) break;
        if(c == '1') if(add_()) {system("cls");printf("\n\n\n");show();continue;}
        if(c == '2') if(delete_()) {system("cls");printf("\n\n\n");show();continue;}
        if(c == '3') if(revise_()) {system("cls");printf("\n\n\n");show();continue;}
        if(c == '4') if(seek_()) {system("cls");printf("\n\n\n");show();continue;}
        if(c == '5') {showall();system("cls");printf("\n\n\n");show();continue;}
    }
    return 0;
}

相当不错的一个成绩管理系统 #include #include #include #include using namespace std; enum {SUBJECT=5};//一共五门 typedef struct { char subject[10];//科目名称 int score;//科目成绩 }markinfo; typedef struct studentnode { markinfo mark[SUBJECT]; int totalmark; char name[10];//学生姓名 studentnode * next; }studentnode; class student { studentnode * head; public: student(); int addstudent(); ~student(); int countmark(); int sortbymark(); int save(); int show(); int display(); int readfiletolist(); int searchbyname(); }; student::student() //用构造函数来初始化。 { head=new studentnode; head->next=NULL; } //1.输入学生姓名、成绩等数据,并保存在链表中。 int student::addstudent() { studentnode * p; int i; char check; system("cls"); cout<<"**********************"<<endl; cout<<"请输入学生信息:"<<endl; do { p=new studentnode; cin.ignore(); cout<name); i=0; p->totalmark=0; do { cout<mark[i].subject); cout<>p->mark[i].score; } while(p->mark[i].score>100||p->mark[i].scoretotalmark=p->totalmark+p->mark[i].score; getchar(); } while(++i!=SUBJECT); if(head->next==NULL) { head->next=p;p->next=NULL; } else { p->next=head->next; head->next=p; } cout<next; if(p==NULL) { cout<<"没有学生,请重新输入"<<endl;system("pause");return 0; } else { cout<<"***************"<<endl; cout<<"学生成绩汇总:"<<endl; while(p) { cout<<"姓名:"<name<<" 总成绩:"<totalmark<next; } } system("pause"); return 0; } //4.输出所有学生成绩到一个文件中。 int student::save() { char address[35]; int i; studentnode * p=head->next; cout<<"请输入保存的地址"<<endl; cin.ignore(); gets(address); ofstream fout; fout.open(address,ios::app|ios::out); while(p) { fout<<"*"; fout<name<<"*"; i=0; while(i!=SUBJECT) { fout<mark[i].subject<<"*"; fout<mark[i].score; i++; } //fout<next; } fout.flush(); fout.close(); cout<next; while(p) { s=p->next; delete p; p=s; } delete head; } //3.按照总成绩大小对记录进行排序 int student::sortbymark() { studentnode *move1=head->next; studentnode *move2,*max,*pre1,*pre2,*maxpre,*s=move1; if(head->next==NULL) { cout<<"没有记录,请添加"<next!=NULL;pre1=move1,maxpre=pre1,move1=move1->next,max=move1) { for(pre2=move1,move2=move1->next;move2!=NULL;pre2=move2,move2=move2->next) if(move2->totalmark>max->totalmark) { maxpre=pre2; max=move2; } if(move1->next==max) //交换max和move1。 { pre1->next=max; move1->next=max->next; max->next=move1; move1=max; } else { s=move1->next; move1->next=max->next; max->next=s; maxpre->next=move1; pre1->next=max; move1=max; } } cout<<"已经按照从大到小排序"<next; int i; if(head->next==NULL){cout<<"没有学生记录,请添加"<<endl;system("pause"); return 0;} else { while(p) { cout<<"姓名:"<name; i=1; while(i!=SUBJECT+1) { cout<<"科目:"<mark[i-1].subject; cout<<" 成绩:"<mark[i-1].score; i++; } cout<next; } } system("pause"); return 0; } //6:从文件按读取记录 int student::display() { ifstream fin; char buf[100]; char str[25]; cout<<"请输入路径及文件名:"<<endl; cin.ignore(); gets(str); fin.open(str); if(!fin) { cout<<"没有此文件"<<endl; system("pause"); return 0; } while(fin) { fin.getline(buf,sizeof(buf)); cout<<buf<<endl; } system("pause"); return 0; } //8从文件中读取数据,并将数据保存在链表中 int student::readfiletolist() { ifstream fin; int i; char str[25]; cout<<"请输入路径及文件名:"<<endl; cin.ignore(); gets(str); fin.open(str); if(!fin) { cout<<"没有此文件"<totalmark=0; fin.getline(p->name,100,'*'); i=0; while(i!=SUBJECT) { fin.getline(p->mark[i].subject,100,'*'); fin>>p->mark[i].score; p->totalmark+=p->mark[i].score; i++; } if(head->next==NULL) { head->next=p; p->next=NULL; } else { p=head->next; head->next=p; } } cout<<"信息已经保存在链表中"<next==NULL) { cout<<"没有学生,请添加或者从文件中读取"<next; char findname[10]; int i; cout<name,findname)) { cout<<"经查找,找到该生信息如下:"<<endl<<endl; cout<<"姓名:"<name; i=1; while(i!=SUBJECT+1) { cout<<"科目:"<mark[i-1].subject; cout<<" 成绩:"<mark[i-1].score; i++; } cout<next; } cout<<"没有此学生,请添加或者从文件中读取"<<endl; system("pause"); return 0; } int showmenu() { int choice; char * menu[9]={ "1:输入学生成绩保存到链表\n", "2:计算每位学生总成绩\n", "3:按照总成绩大小对记录进行排序\n", "4:输出所有学生成绩到一个文件中\n", "5:显示新输入的学生信息\n", "6:从文件中读取信息\n", "7:将文件信息保存在链表中\n", "8:根据姓名查找学生记录\n", "9:结束程序\n" }; cout<<" "<<"*****************************************************"<<endl; cout<<" *"<<" "<<"学生成绩管理系统"<<" *"<<endl; cout<<" "<<"*****************************************************"<<endl; for(choice=0;choice<9;choice++) cout<<" "<<menu[choice]; cout<<" "<<"*****************************************************"<<endl; cout<<"please choose to continue"<>choice; } while(choice>9||choice<1); return choice; } int main() { int menuitem,flag=1; student stu; while(flag) { system("cls"); menuitem=showmenu(); switch(menuitem) { case 1:{stu.addstudent();break;} case 2:{stu.countmark();break;} case 3:{stu.sortbymark();break;} case 4:{stu.save();break;} case 5:{stu.show();break;} case 6:{stu.display();break;} case 7:{stu.readfiletolist();break;} case 8:{stu.searchbyname();break;} case 9:{flag=0;break;} } } return 0; }
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值