亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求大神指教 c++程序設計(學生評教系統)

求大神指教 c++程序設計(學生評教系統)

C++
愛不凡 2015-05-30 17:09:30
//設計一個學生評教系統,系統主要處理學生評教的相關信息。//其中,學生信息主要包括:學號、姓名、性別、聯系電話等內容,//教師信息主要包括:教師編號、教師名稱、任教課程編號、任教課程名、評教成績等內容,//請按照以下的功能要求設計系統。//【功能要求】//(1)定義學生類、教師類、評教類;//(2)輸入:學生、教師、評教信息的錄入;//(3)輸出:學生、教師、評教信息的輸出;//(4)編輯功能:可進對學生、教師、評教信息執行查詢、修改、添加、刪除等操作;//(5)菜單功能:每種功能的操作都是在菜單中進行相應選擇;//(6)最好用文件保存信息數據。#include<iostream>#include<fstream>#include<string.h>#include<conio.h> ? ? ? ? ? ? ?//用getch();using namespace std;//學生類class student{public:? ? char Id[20];? ? char name[10];? ? char sex[3]; long telephone; student*Next; //student(long xh,char nm[],char sx[],long tel) //{ // xuehao=xh; // strcpy(name, nm); // strcpy(sex, sx); // telephone = tel; //} void newstudent(); void input() { cout << "學號:"; cin >> Id; cout << "姓名:"; cin >> name; cout << "性別:"; cin >> sex; cout << "電話:"; cin >> telephone; } void ReadFile(istream&in) { cin >> Id >> name >> sex >> telephone; } void show() const { cout << "學號" << Id; cout << "姓名" << name; cout << "性別" << sex; cout << "電話" << telephone; }}newstudent;//教師類class teacher{public: long teachernumber; char name[10]; long classnumber; char classname[10]; char commentperformance[100]; /*teacher(long tnum, char nm[], long cnum, char cnm[], char comper[]) { teachernumber = tnum; strcpy(name, nm); classnumber = cnum; strcpy(classname, cnm); strcpy(commentperformance, comper); }*/ void teacherinput() { cout << "教師編號:"; cin >> teachernumber; cout << "教師名稱:"; cin >> name; cout << "任教課程編號:"; cin >> classnumber; cout << "任教課程名:"; cin >> classname; cout << "評教成績:"; cin >> commentperformance; } void show()? { cout << "教師編號:"<< teachernumber; cout << "教師名稱:"<< name; cout << "任教課程編號:"<<classnumber; cout << "任教課程名:"<<classname; cout << "評教成績:"<<commentperformance; }};//評教類class commentsystem{public: commentsystem(); ~commentsystem(); void showmenu(); void showinformation(); void find(); void save(); void modifyinformation(); void removeinformation(); void swap(student*, student*); void display() { for (student*p = Head->Next; p != End;p=p->Next) p->show(); cout << "輸入任意字符!繼續……"; getch(); } void addinformation() { End->input(); End->Next = newstudent(); End = End->Next; cout << "添加成功!" << endl; cout << "輸入任意字符!繼續……"; getch(); }private: student*Head, *End; ifstream in; ofstream out; student*FindItem(char*name) { for (student*p = Head; p->Next != End; p = p->Next)//匹配成功則返回上一個指針,不成功就返回空 if (!strcmp(p->Next->name, name))return p; return NULL; } student*FindID(char*Id) { for (student*p = Head; p->Next != End; p = p->Next)//匹配成功則返回上一個指針,不成功就返回空 if (!strcmp(p->Next->Id, Id))return p; return NULL; }};//構造函數commentsystem::commentsystem(){ Head = newstudent; Head->Next = newstudent; End = Head->Next; in.open("D:/sort.txt"); if (!in) cout << "這是一個新系統,無學生信息。請先輸入。" << endl; else { while (!in.eof()) { End->ReadFile(in); if (End->name[0] == '\0')break; End->Next = newstudent; End = End->Next; } in.close(); cout << "\t\t讀取學生信息成功!" << endl; }}//析構函數commentsystem::~commentsystem(){ save(); for (student*temp; Head->Next != End;) { temp = Head->Next; Head->Next = Head->Next->Next; delete temp; } delete Head, End;}//菜單void commentsystem::showmenu(){ cout << "^^^^^^^^^^學生評教系統^^^^^^^^^^" << endl; cout << "^^^^^^^^^^1.輸入學生信息^^^^^^^^^^" << endl; cout << "^^^^^^^^^^2.輸入教師信息^^^^^^^^^^" << endl; cout << "^^^^^^^^^^3.輸入評教信息^^^^^^^^^^" << endl; cout << "^^^^^^^^^^4.查找信息^^^^^^^^^^" << endl; cout << "^^^^^^^^^^5.刪除信息 ^^^^^^^^^^" << endl; cout << "^^^^^^^^^^6.修改信息^^^^^^^^^^" << endl; cout << "^^^^^^^^^^0.退出^^^^^^^^^^" << endl; cout << "請選擇:";}//查找函數void commentsystem::find(){ char name[20], Id[10]; int x; student*p = NULL; cout << "\n\t\t*********************************\n"; cout << "\t\t※1.按學生的姓名查找\n\t\t※2.按學生學號查找"; cout << "\n\t\t*********************************\n請選擇:"; cin >> x; switch (x) { case 1:{cout << "\t\t請輸入要查找的學生的姓名:"; cin >> name; if (p = FindItem(name)) { p->Next->show(); cout << "輸入任意字符!繼續……"; getch(); } else { cout << "\t\t沒有找到該姓名的學生!" << '\n' << endl; cout << "輸入任意字符!繼續……"; getch(); } }break; ?case 2: { cout << "\t\t請輸入要查找的學生的學號:"; cin >> Id; if (p = FindID(Id)) { p->Next->show(); cout << "輸入任意字符!繼續……"; getch(); } else { cout << "\t\t沒有找到該學好的學生!" << '\n' << endl; cout << "輸入任意字符!繼續……"; getch(); } }break; default:cout << "輸入有誤"; }}//修改信息void commentsystem::modifyinformation()//修改信息{ char name[20]; student*p = NULL; cout << "\t\t請輸入要修改的人的姓名:"; cin >> name; if (p = FindItem(name)) { cout << "\t\t已找到學生的信息,請輸入新的信息!" << endl; p->Next->input(); cout << "修改成功!" << endl; cout << "輸入任意字符!繼續……"; getch(); } else { cout << "\t\t沒有找到!" << endl; cout << "輸入任意字符!繼續……"; getch(); }}//刪除信息void commentsystem::removeinformation()//刪除信息{ char name[20]; student*p = NULL, *temp = NULL; cout << "\t\t請輸入要刪除的學生的姓名:" << endl; cin >> name; if (p = FindItem(name)) { temp = p->Next; p->Next = p->Next->Next; delete temp; cout << "\t\t刪除成功!" << endl; cout << "輸入任意字符!繼續……"; getch(); } else { cout << "\t\t沒有找到!" << endl; cout << "輸入任意字符!繼續……"; getch(); }}//保存函數void commentsystem::save(){ out.open("sort.txt"); for (student*p = Head->Next; p != End; p = p->Next) out << p->name << "\t" << p->Id << "\t" << p->sex << "\t" << p->telephone << '\n'; out.close();}//主函數int main(){ int x, i = 0; bool quit = false; cout << "\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§" << endl; for (i = 0; i<3; i++) cout << "\t\t◎\t\t\t\t\t\t◎" << endl; cout << "\t\t◎★★★★【歡迎進入學生成績管理系統】★★★★◎" << endl; for (i = 0; i<3; i++) cout << "\t\t◎\t\t\t\t\t\t◎" << endl; cout << "\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§\n" << endl;; commentsystem Grade; cout << "按任意鍵開始……"; getch(); while (!quit) { system("cls"); Grade.showmenu(); cin >> x; switch (x) { case 0:quit = true; break; case 1:Grade.addinformation(); break; case 2:Grade.display(); break; case 4:Grade.find(); break; case 5:Grade.removeinformation(); break; case 6:Grade.modifyinformation(); break; default:cout << "輸入有誤"; } } return 0;}
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 3028 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號