当前位置: 首页 > news >正文

江门网站免费制作重庆信息网官网

江门网站免费制作,重庆信息网官网,wordpress调用分类产品,wordpress动漫本文通过STL类库的list数据结构来完成学生管理系统#xff0c;采用链表内排序#xff0c;通过list类库自带sort函数进行排序。 注意#xff1a;此时排序规则函数定义为类静态成员函数#xff0c;等价于全局函数函数指针定义为 BY_FUNC ps[] { CStudent::byNumb,CStudent:…本文通过STL类库的list数据结构来完成学生管理系统采用链表内排序通过list类库自带sort函数进行排序。 注意此时排序规则函数定义为类静态成员函数等价于全局函数函数指针定义为 BY_FUNC ps[] { CStudent::byNumb,CStudent::byName,CStudent::byMath }; C中定义CStudent类 文件名Student.h #pragma once #include list typedef struct SUser {int nNumb;char sName[20];float fMath; }DATA;//using namespace std; //头文件中最好不要usingtypedef bool (*BY_FUNC)(DATA q, DATA m);class CStudent {std::listDATA m_list;int Menu();int Input();bool Delete();void Modify();void Print();//void Sort(BY_FUNC pFunc);int SortMenu();void Load();void Save();//void PrintPS(POSITION* ps);bool Check(int nNumb);int FindMenu();//void FindByNumb();static bool byNumb(DATA q, DATA m) // 静态成员函数{return q.nNumb m.nNumb;}static bool byName(DATA q, DATA m){return strcmp(q.sName, m.sName) 0;}static bool byMath(DATA q, DATA m){return q.fMath m.fMath;} public:CStudent();~CStudent();void Start(); };类成员函数实现 文件名Student.cpp #define _CRT_SECURE_NO_WARNINGS#include Student.h #include iostream #include conio.h using namespace std;bool CStudent::Check(int nNumb) {listDATA::iterator it m_list.begin();while (it!m_list.end()){if (it-nNumb nNumb)return true;it;}return false; }int CStudent::FindMenu() {return 0; }CStudent::CStudent() { }CStudent::~CStudent() { }void CStudent::Start() {Load();while (Menu()); }int CStudent::SortMenu() {system(cls);puts(1.按学号排序);puts(2.按姓名排序);puts(3.按成绩排序);puts(4.不排序);puts(0.返回主菜单);int i 0;cin i;BY_FUNC ps[] { CStudent::byNumb,CStudent::byName,CStudent::byMath };switch (i){case 1:case 2:case 3:m_list.sort(ps[i - 1]);case 4:Print();default:return i;}return i; }void CStudent::Load() {FILE* pf fopen(stud.lv, r);if (!pf){puts(加载文件时失败);system(pause);return;}DATA t;while (fread(t, 1, sizeof(DATA), pf) sizeof(DATA))m_list.push_back(t);fclose(pf); }void CStudent::Save() {FILE* pf fopen(stud.lv, w);if (!pf){puts(保存文件时失败);system(pause);return;}listDATA::iterator it m_list.begin();while (it!m_list.end()){fwrite((*it), 1, sizeof(DATA), pf);it;}fclose(pf); }int CStudent::Menu() {system(cls);//clear screenputs(\n\t\t1、浏览所有信息);puts(\t\t2、添加信息);puts(\t\t3、删除信息);puts(\t\t4、修改信息);puts(\t\t5、查找信息);puts(\t\t0、退出);printf(\t\t请选择);int i 0;cin i;switch (i){case 1:while (SortMenu());break;case 2:while (Input());break;case 3:while (Delete());break;case 4:Modify();break;case 5:while (FindMenu());}return i; }int CStudent::Input() {cout 请输入学号;DATA d;while (true){cin d.nNumb;if (Check(d.nNumb))cout 学号已存在请重新输入;elsebreak;}cout 请输入姓名和数学成绩空格间隔;cin d.sName d.fMath;m_list.push_back(d);Save();Print();cout 是否继续添加[y/n];rewind(stdin);char c getchar();return c y || c Y; }bool CStudent::Delete() {int nNumb;Print();cout 请输入要删除的学号;cin nNumb;listDATA::iterator it m_list.begin();while (it!m_list.end()){if (it-nNumb nNumb){m_list.erase(it);Print();cout 删除成功 endl;system(pause);Save();return false;}it;}cout 你输入的学号不存在是否继续删除[y/n];char c _getch();putchar(c);puts();return y c || Y c; }void CStudent::Modify() { }void CStudent::Print() {listDATA::iterator it m_list.begin();cout 学号\t姓名\t成绩 endl;while (it!m_list.end()){cout it-nNumb \t it-sName \t it-fMath endl;it;}system(pause); }主函数 文件名main.cpp #include Student.h void main() {CStudent st;st.Start(); }
http://www.yutouwan.com/news/138405/

相关文章:

  • 网站开发经理招聘极验验证+wordpress
  • 国外网站空间租用费用临沂做百度网站软件公司
  • 网站制作公司报价网站系统维护一个月正常吗
  • 沈阳市浑南区城乡建设局网站在线图片修改
  • php网站系统东莞网站关键词优化哪家好
  • 企业网站建设管理平台如何查注册商标是别人注册过的
  • vi设计网站大全wordpress按照证书
  • 专业做网站上海开设计公司要怎么规划
  • 菏泽网站建设便宜臻动传媒网站建设电商学堂
  • 苏州建设银行网站首页国外性价比高的vps
  • 西安高校定制网站建设公司推荐山西网站的公司
  • 买卖网站建设电商网站建设分析
  • 一个dede管理两个网站东莞松山湖风景区
  • 国外虚拟服务器网站广州行业门户网站建设
  • 网页设计做一个介绍自己的的网站wordpress 微信同步
  • 聊城网站案例网站名字大全
  • h5成品网站做网站需要套模板
  • 北京seo网站结构优化网站用的服务器多少钱
  • 怎样开通网站太原seo外包公司
  • 网站源码文件安装教程超级商城
  • sns社交网站wordpress inc文件夹
  • 网站群建设工作如何在手机上做自己的网站
  • 黄山家居网站建设怎么样网站建设前端和后端的区别
  • 上海好的网站设计公司有哪些男女做微电影网站
  • 贵阳网站建设制作方法建设和管理环保网站
  • word如何做网站链接重庆大渝网官网
  • 网站建设公司浩森宇特wordpress 京东导购
  • 邯郸商城网站建站重庆网络推广平台
  • 广西建设领域证书查询官方网站中国建设部网站能查叉车证
  • 企业家网站建设西安代做网站