张孝祥java就业培训教程(完整版电子书)(普通.rar
张孝祥java就业培训教程(完整版电子书)(普通.rar
张孝祥讲解的java通俗易懂,容易理解。
jdk-1_5_0_04
jdk-1_5_0_04-windows-i586-p
学生管理系统程序源代码
学生管理系统程序
#include
using namespace std;
#include
double avg=0;//统计总分和加平均分权
const int mathp=4;//数学学分
const int cppp=5;//C++学分
const sum=70;//设置总学分
class Student
{
private:
int num;
char *name;
char *sex;
char *phone;
char *rphone;
double math;
double cpp;
Student* next;
public:
Student()
{next=NULL;}
~Student();
void Push(Student **refhead,int num,char *name,char *sex,char *phone,char *rphone,double math,double cpp);
void Delete(Student *head,int data);
Student* Find(Student* head,int data);
void Display(Student* head);
int Length(Student* head);
void Math(Student* head,int data);
void Update(Student* head,int data);
void Insert();
};
Student* head=new Student;//带头结点的头指针
void Student::Push(Student **refhead,int num,char *name,char *sex,char *phone,char *rphone,double math,double cpp)
{
Student* newnode=new Student;//新增加结点
newnode->num=num;
newnode->name=name;
newnode->sex=sex;
newnode->phone=phone;
newnode->rphone=rphone;
newnode->math=math;
newnode->cpp=cpp;
newnode->next=*refhead;
*refhead=newnode;//重置表头
}
//遍历
void Student::Display(Student* head)
{
Student* temp;
temp=head;
if(temp->next==NULL)//判断空表
cout<<"没有学生!";
else
{while(temp!=NULL)//
{
cout<<"学号:"<num<<"姓名:"<name<<"性别:"<sex<<"手机:"<phone<<"宿舍电话:"<rphone<<"数学成绩:"<math<<"C++成绩:"<cpp<next;
}
}
return;
}
//人数
int Student::Length(Student* head)
{
Student* cur;
cur=head;
int count=0;
while(cur!=NULL)
{
count++;//通过累加统计人数
cur=cur->next;
}
return count;
}
//查找
Student* Student::Find(Student* head,int data)
{
Student* cur=head;
bool bo=false;
while(cur!=NULL)
{
if(cur->num=data)
{
bo=true;//如果找到则改变bo的值
cout<<"学号:"<num<<"姓名:"<name<<"性别:"<sex<<"手机:"<phone<<"宿舍电话:"<rphone<<"数学成绩:"<math<<"C++成绩:"<cpp<next;
}
if(bo==false)//通过判断bo的值判断找到与否
cout<<"没有这个人!"<num==data)
break;
else
{bef=cur;cur=cur->next;}
}
if(cur==head)//如果是头结点则删除头结点
{
head=cur->next;
delete cur;
}
else
{
bef->next=cur->next;
delete cur;
}
}
//修改
void Student::Update(Student* head,int data)
{
Student* cur=head;
bool bo=false;
while(cur!=NULL)
{
if(cur->num==data)
{
bo=true;
int a,b;
char *c;
double d;
for(;;) //找到后提供各字段的修改
{ cout<>a;
switch(a)
{
case 1:cout<>b;
cur->num=a;
break;
case 2:cout<>c;
cur->name=c;
break;
case 3:cout<>c;
cur->sex=c;
break;
case 4:cout<>c;
cur->phone=c;
break;
case 5:cout<>c;
cur->rphone=c;
break;
case 6:cout<>d;
cur->math=d;
break;
case 7:cout<>d;
cur->cpp=d;
break;
case 8:exit(1);
break;
default:cout<<"操作错误";
break;
}
}
break;
}
}
if(bo==false)
cout<<"没有这个人!"<num=data)
{
bo=true;
avg=cur->math*(mathp/sum)+cur->cpp*(cppp/sum);//计算总分和加平均分权的公式
break;
}
cur=cur->next;
}
if(bo==false){
cout<<"没有这个人!"<<endl;
return;
}
cout<<"该生的总分和加平均分权="<<avg<<endl;
return;
}
//录入
void Student::Insert()
{
head=NULL;
int num;
char name[8];
char sex[4];
char phone[11];
char rphone[7];
double math;
double cpp;
cout<<"请输入基本信息:\n";
cout<>num;
cout<>name;
cout<>sex;
cout<>phone;
cout<>rphone;
cout<>math;
cout<>cpp;
Push(&head,num,name,sex,phone,rphone,math,cpp);//调用函数Push建立有序链表
}
//用释构函数逐个释放空间
Student::~Student()
{
while(head!=NULL)
{
delete head;
head=head->next;
}
}
//程序主入口
void main()
{
for(;;)
{
head=NULL;
Student s;
int x;
int data;
cout<<"|1录入|2查找|3删除|4修改|5统计|6退出|\n";
cout<>x;
switch(x)
{
case 1:
start:
s.Insert();
cout<>ch;
if(ch=='y' || ch=='Y')
goto start;
s.Display(head);
int l;
l=s.Length(head);
cout<<"一共有"<<l<<"个学生。"<<endl;
break;
case 2:
cout<>data;
s.Find(head,data);
break;
case 3:
cout<>data;
s.Delete(head,data);
break;
case 4:
cout<>data;
s.Update(head,data);
break;
case 5:
cout<>data;
s.Math(head,data);
break;
case 6:
exit(1);
break;
default:cout<<"操作错误!"<<endl;
break;
}
}}
自考软件工程心得体会
自考软件工程心得体会 (一)纸上得来终觉浅,觉知此事要躬行(二)吾生也有涯,而知也无涯