找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 1630|回复: 0

[原创]再发一个学生管理系统!

[复制链接]
发表于 2009-11-6 00:14:23 | 显示全部楼层 |阅读模式 IP:江苏扬州
#include <iomanip>
#include <iostream>
#include <fstream>
#include <vector>
#include <conio.h>
#include <stdlib.h>
#include <string>
#include <process.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
struct student
{
char name[10]; /// 姓名
char id[10]; /// 学号
float Ynum; /// 语文分数
float Snum; /// 数学分数
float Enum; /// 英语分数
float number; /// 总分
student *next;
};
///////////-------定义类---------------////////////
class stud
{
student *p1,*p2,*head;
public:
~stud() /////----析构函数------------
{
while(head)
{
p1=head->next;
delete head;
head=p1;
}
}
///------------成员函数------------
void output(student *head); // 输出学生成绩
student * input(student *head); // 增加学生记录
student* del(student *head, char*p); // 删除记录
student* find(student *head,char *p,int &n); // 查找学生记录(可查找多个同名数据)
student* stat(student *head); //排序统计学生总分
friend void total(student*head); //统计学生总分
student* insert(student *head); //按学生总分插入记录
student* clear(student *head); // 删除当前表
void Inputs(student *p); //用于添加数据的子函数
};//----------------------------------------------------
////---------用于添加数据的子函数-------///////
void stud::Inputs(student*p)
{
cout<<setw(6)<<"姓名"<<setw(8)<<" 学号"
<<setw(8)<<"语文"<<setw(8)<<"数学"
<<setw(8)<<"英语"<<endl;
cin>>p->name >>p->id;
cin >>p->Ynum;
while(cin.fail())
{ cerr<<"您的输入有误,请重新输入"<<endl;
cin.clear ();
cin.sync ();
cin>>p->Ynum;
}
cin>>p->Snum;
while(cin.fail())
{ cerr<<"您的输入有误,请重新输入"<<endl;
cin.sync ();
cin.clear ();
cin>>p->Snum;
}
cin>>p->Enum;
while(cin.fail())
{ cerr<<"您的输入有误,请重新输入"<<endl;
cin.clear ();
cin.sync ();
cin>>p->Enum;
}
total(p); //计算出总分
}
////////-----输出学生成绩-----------------/////////////////////
void stud::output (student *head)
{ p1=head;
while(p1!=NULL)
{
cout<<setw(6)<<p1->name<<setw(8)
<<p1->id<<setw(8)<<p1->Ynum
<<setw(8)<<p1->Snum <<setw(8)
<<p1->Enum <<setw(7)<<p1->number <<endl;
p1=p1->next ;
}
}
/////////------------插入学生成绩记录--------////////////////
student* stud::insert(student *head)
{
p1=new student;
Inputs(p1); //调用子函数 增加数据

p2=head;
student* p3=NULL;
while((p2->number < p1->number ) && p2->next !=NULL)
{ p3=p2;
p2=p2->next;
}
if(p2->number > p1->number)
{ p1->next=p2;
if(p3==NULL) // 若当前值是最小的
return p1;
p3->next =p1;
return head;
}
else
{ p2->next=p1;
p1->next=NULL;
return head;
}
}
//////----------清空数据------------/////////////
student* stud::clear(student*head)
{
while(head)
{ p1=head->next ;
delete head;
head=p1;
}
return head;
}
//////////-----------排序统计函数-----------/////////////////
student *stud::stat(student *head)
{
p2=head;
p1=p2->next;
while(p2->next) //冒泡泡法, 呵呵`~~~
{

if(p2->number > p1->number)
{ // 把头指针指向当前比较小的节点
p2->next=p1->next;
p1->next=head;
head=p1;
// 把用于比较的两个指针复位
p2=head;
p1=p2->next ;
}
else
{ // 指向下一个节点
p2=p2->next ;
p1=p2->next ;
}//--------
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-10-1 12:18 , Processed in 0.191200 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表