数据结构课程设计(考试管理系统)
生活随笔
收集整理的這篇文章主要介紹了
数据结构课程设计(考试管理系统)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
為考試報(bào)名管理人員編寫一個(gè)考試報(bào)名管理系統(tǒng)?,用菜單選擇方式完成下列功能:
1.考生報(bào)名信息添加:包括準(zhǔn)考證號(hào)、姓名、性別、年齡、學(xué)院、專業(yè)、班級(jí)、身份證號(hào)、報(bào)考科目(eg. CET4/CET6)等。
2.考生報(bào)名信息查詢:分別按姓名、學(xué)院、專業(yè)、班級(jí)、報(bào)考科目等進(jìn)行查詢。
3.排序:分別根據(jù)姓名、年齡、學(xué)院等按升序進(jìn)行排序。
4.考生報(bào)名信息的修改、刪除:按準(zhǔn)考證號(hào)進(jìn)行考生信息的修改和刪除。
長(zhǎng)期手懶,現(xiàn)在寫的程序越來越瓜皮了。
先貼一個(gè)cpp文件
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<windows.h>
#include<conio.h>
#include"datastructure.h"
using namespace std; #define maxn 1000 int menu()
{
??? cout<<"\t\t歡迎來到考試報(bào)名系統(tǒng)!選擇你想要的服務(wù)"<<endl;
??? cout<<"\t\t\t 1.考生報(bào)名信息添加"<<endl;
??? cout<<"\t\t\t 2.考生報(bào)名信息查詢"<<endl;
??? cout<<"\t\t\t 3.考生排序"<<endl;
??? cout<<"\t\t\t 4.考生信息修改和刪除"<<endl;
??? return 0;
} int ask(char ch)
{
??? cout<<"是否繼續(xù)此操作?(y/n)"<<endl;
??? ch=getche();
??? if(ch=='y')
??? {
??? system("cls");
??? menu();
??? return 1;
??? }
??? else
??? {
??? system("cls");
??? menu();
??? return 0;
??? }
} int InitList(SQL &L)
{
??????? L.s = new CET[maxn];
??????? if (!L.s) exit(-1);
??????? else
??????????????? L.length = 0;
??????? return 0;
} int add(SQL &L,int i)
{
??????? cout << "請(qǐng)輸入第"<<i++<<"個(gè)學(xué)生的信息!\n";
??????? cout << "準(zhǔn)考證號(hào):" << endl;
??????? cin >> L.s[L.length].adcard;
??????? cout << "姓名:" << endl;
??????? cin >> L.s[L.length].name;
??????? cout << "性別:" << endl;
??????? cin >> L.s[L.length].sex;
??????? cout << "年齡:" << endl;
??????? cin >> L.s[L.length].age;
??????? cout << "學(xué)院:" << endl;
??????? cin >> L.s[L.length].academy;
??????? cout << "專業(yè):" << endl;
??????? cin >> L.s[L.length].major;
??????? cout << "班級(jí):" << endl;
??????? cin >> L.s[L.length].grade;
??????? cout << "身份證號(hào):" << endl;
??????? cin >> L.s[L.length].idcard;
??????? cout << "報(bào)考科目:" << endl;
??????? cin >> L.s[L.length].subject;
??????? ++L.length;
??????? cout<<"信息添加成功!"<<endl;
??????? return 0;
} int print_info(SQL &L, int i)
{
??????? cout << "姓名:? " << L.s[i].name << endl;
??????? cout << "準(zhǔn)考證號(hào):? " << L.s[i].adcard << endl;
??????? cout << "年齡:? " << L.s[i].age << endl;
??????? cout << "性別:? " << L.s[i].sex << endl;
??????? cout << "學(xué)院:? " << L.s[i].academy << endl;
??????? cout << "專業(yè):? " << L.s[i].major << endl;
??????? cout << "班級(jí):? " << L.s[i].grade << endl;
??????? cout << "身份證號(hào):? " << L.s[i].idcard << endl;
??????? cout << "報(bào)考科目:? " << L.s[i].subject << endl<<endl;
??????? return 0;
}
int besearch(SQL &L)
{
??????? bool flag = false;
??????? string s;
??????? cout << "填入你要查找的信息:" << endl;
??????? cout << "1.?? 姓名"<<endl<<"2.?? 學(xué)院"<<endl<<"3.?? 專業(yè)"<<endl<<"4.?? 報(bào)考科目"<<endl;
??????? cin >> s;
??????? getchar();
??????? for (int i = 0; i < L.length; i++)
??????? {
??????????? if ((L.s[i].name == s||L.s[i].academy==s||L.s[i].major==s||L.s[i].subject==s)&&L.s[i].have)
??????????????? {
??????????????? flag = true;
??????????????? print_info(L, i);
??????????????? }
??????? }
??????? if (!flag) cout << "查找失敗!" << endl;
??????? return 0;
} int sort_info(SQL &L)
{
??? char op;
??? cout<<"1.? 按姓名排序"<<endl<<"2.? 按年齡排序"<<endl<<"3.? 按學(xué)院排序"<<endl;
??? cin>>op;
??? if(op=='1')
??? {
??????? for(int i=0;i<L.length-1;i++)
??????????? for(int j=0;j<L.length-i-1;j++)
??????????? if(L.s[j].name<L.s[j+1].name)
??????????? {
??????????? CET* p=new CET;
??????????? *p=L.s[j];
??????????? L.s[j]=L.s[j+1];
??????????? L.s[j+1]=*p;
??????????? }
??? }
??? if(op=='2')
??? {
??????? for(int i=0;i<L.length-1;i++)
??????????? for(int j=0;j<L.length-i-1;j++)
??????????? if(L.s[j].age<L.s[j+1].age)
??????????? {
??????????? CET* p=new CET;
??????????? *p=L.s[j];
??????????? L.s[j]=L.s[j+1];
??????????? L.s[j+1]=*p;
??????????? }
??? }
??? return 0;
} int modify(SQL &L)
{
??? bool flag = false;
??? string s;
??? char op,op2;
??? int i;
??? cout<<"選擇你所需要的服務(wù):"<<endl<<"1.??? 修改信息"<<endl<<"2.??? 刪除信息"<<endl;
??? cin>>op;
??? cout<<"輸入準(zhǔn)考證號(hào):"<<endl;
??? cin>>s;
??? for (i = 0; i < L.length; i++)
??? {
??????? if (L.s[i].adcard == s&&L.s[i].have)
??????? {
??????? flag = true;
??????? print_info(L, i);
??????? }
??? }
??? if (!flag) {cout << "查找失敗!" << endl; return -1;}
??? if(op=='1')
??? {
??????? cout<<"選擇你需要修改的項(xiàng)目!"<<endl;
??????? cout << "1.?? 姓名"<<endl<<"2.?? 年齡"<<endl<<"3.?? 性別"<<endl<<"4.?? 身份證號(hào)"<<endl<<"5.?? 準(zhǔn)考證號(hào)"<<endl;
??????? cout << "6.?? 學(xué)院"<<endl<<"7.?? 專業(yè)"<<endl<<"8.?? 班級(jí)"<<endl<<"9.??? 報(bào)考科目"<<endl;
??????? op2=getchar();
??????? switch(op2)
??????? {
??????????? case '1': cout << "性別:" << endl;cin >> L.s[i].sex; break;
??????????? case '2': cout << "年齡:" << endl;cin >> L.s[i].age; break;
??????????? case '3': cout << "性別:" << endl;cin >> L.s[i].sex; break;
??????????? case '4': cout << "身份證號(hào):" << endl;cin >> L.s[i].idcard; break;
??????????? case '5': cout << "準(zhǔn)考證號(hào):" << endl;cin >> L.s[i].adcard; break;
??????????? case '6': cout << "學(xué)院:" << endl;cin >> L.s[i].academy; break;
??????????? case '7': cout << "專業(yè):" << endl;cin >> L.s[i].major; break;
??????????? case '8': cout << "班級(jí):" << endl;cin >> L.s[i].grade; break;
??????????? case '9': cout << "報(bào)考科目:" << endl;cin >> L.s[i].subject; break;
??????? }
??????? cout<<"修改成功!"<<endl;
??? }
??? if(op=='2')
??? {
??? L.s[i].have=false;
??? cout<<"刪除成功!"<<endl;
??? }
??? return 0;
}
然后main文件 #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<windows.h>
#include<conio.h>
#include"datastructure.h"
using namespace std;
int main()
{
??? int n;
??? char op,ch;
??? SQL L;
?InitList(L);
??? menu();
?while(cin>>op)
??? {
??? if(op=='1')
??? {
??????? for(;;)
??????? {
??????? cout<<"\t請(qǐng)輸入學(xué)生人數(shù)!"<<endl;
??????? cin>>n;
??????? for(int i=0;i<n;i++)
??????? add(L,i+1);
??????? if(!ask(ch)) break;
??????? }
??? }
??? else if(op=='2')
??? {
??????? for(;;)
??????? {
??????????? besearch(L);
??????????? if(!ask(ch)) break;
??????? }
??? }
??? else if(op=='3')
??? {
??????? for(;;)
??????? {
??????? sort_info(L);
??????? cout<<"排序成功,是否需要輸出?(y/n)"<<endl;
??????? char c;
??????? cin>>c;
??????? if(c=='y')
??????? for (int i = 0; i < L.length; i++)
??????? print_info(L,i);
??????? if(!ask(ch)) break;
??????? }
??? }
??? else if(op=='4')
??? {
??????? for(;;)
??????? {
??????? modify(L);
??????? if(!ask(ch)) break;
??????? }
??? }
??? else??? {cout<<"輸入錯(cuò)誤,請(qǐng)重新輸入!\n";continue;}
??? }
?return 0;
}
最后頭文件 #ifndef DATASTRUCTURE_H_INCLUDED
#define DATASTRUCTURE_H_INCLUDED
#include<iostream>
#include<string>
#include<cstdio>
using namespace std; struct CET
{
??? bool have=true;
?string adcard,name,sex,academy,major,idcard,subject;
?int age,grade;
}; struct SQL
{
?CET *s;
?int length;
}; int menu();
int ask(char ch);
int InitList(SQL &L);
int add(SQL &L,int i);
int print_info(SQL &L,int i);
int besearch(SQL &L);
int sort_info(SQL &L);
int modify(SQL &L);
#endif // DATASTRUCTURE_H_INCLUDED
總結(jié)
以上是生活随笔為你收集整理的数据结构课程设计(考试管理系统)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FFmpeg基础:音视频同步播放
- 下一篇: HTML5 APP开发与原生态APP比较