谁会啊,帮帮忙啦,把程序编给我啊
谁会啊,帮帮忙啦,把程序编给我啊
 2006-12-19 22:43
	    2006-12-19 22:43
   2006-12-20 08:29
	    2006-12-20 08:29
  






 
										
					
	 2006-12-20 08:33
	    2006-12-20 08:33
  




 
										
					
	 2006-12-20 08:33
	    2006-12-20 08:33
   
										
					
	
 2006-12-20 08:41
	    2006-12-20 08:41
  




 
										
					
	 2006-12-20 09:59
	    2006-12-20 09:59
   2006-12-20 12:16
	    2006-12-20 12:16
  //***************************************************************************************************************************
//------------>学生成绩管理系统
//程序清单:
#include <iostream.h>
#include <iomanip.h>
#include <fstream>
#include <vector>
#include <malloc.h>
#include <stdlib.h>
#include <string>
#include <process.h>
#include <stdio.h>
#define NULL 0
int const Q=20;
#define LEN sizeof(struct student)
using namespace std;
int n=0;  //定义一个全局变量统计学生人数 
//——--------->定义一个学生考试信息的结构体
struct student
{ 
  char name[Q];     //用来存放姓名的
  char sex[Q];      //用来存放性别的
  long int id;      //用来存放准考证号的
  int score[4];     //用来存放分数的
  int total;        //用来存放总分数的
  struct student *next;
};
//student向量容器
vector <student> stu;
//-------------->学生类
class  Information
{   
public:
Information() ;   //构造函数.               
~Information() ;  //析构函数. 
student *creat();//建立链表函数。
    void output(student *head);
    int count(student *head);//定义函数count()统计考生总数
    student *insert(student*head);//指针函数*insert()用来添加考生信息.
    student *cancel(student *head,long int num);//指针函数*cancel()用来删除考生信息.
    student *find(student *head,long int num); //指针函数*find()用来查找考生信息.
    void paixu(student *head);//定义paixu()函数将考生的总分从大到小排列并输出
    void average( student *head);//求学生成绩的平均分的函数
    void save(student *head);//保存函数
    student *Read();//读取函数
private:
student *p1,*p2,*p3,*head,st;  
};

 2006-12-20 15:51
	    2006-12-20 15:51
  
 2006-12-20 15:51
	    2006-12-20 15:51
  
void  Information::output(student *head) 
{
   
    if(head==NULL) cout<<" 这是一个空表,请先输入考生成绩.\n";
    else{
cout<<"-------------------------------------------------------------------------------\n";
    cout<<"                             *学生考试成绩信息表*\n";
    cout<<"-------------------------------------------------------------------------------\n"; 
    cout<<"准考证号   姓  名     性别    数学     物理     英语     C++   平均分     总分\n";
    cout<<"-------------------------------------------------------------------------------\n"; 
    p1=head;//将头指针赋给p  
    do
{
    cout<<setw(8)<<p1->id
        <<setw(9)<<p1->name
        <<setw(8)<<p1->sex
        <<setw(8)<<p1->score[0]
        <<setw(9)<<p1->score[1]
        <<setw(9)<<p1->score[2]
        <<setw(9)<<p1->score[3]
        <<setw(9)<<p1->total/4.0
        <<setw(9)<<p1->total<<endl;
       cout<<"-------------------------------------------------------------------------------\n"; 
       p1=p1->next;//将下一组考生信息的next指针赋给p
}while(p1!=NULL);//若指针p非空则继续,目的是把所有的考生信息都传给指针p然后输出.
}
}
//------------>统计学生人数的函数
int  Information::count(struct student *head)//定义函数count()统计考生总数
{
if(head==NULL)return(0);//若指针head为空返回值为0
    else return(1+count(head->next));//函数的递归调用
}
//----------->插入学生的成绩的函数
student *Information::insert( student *head) 
//插入新结点定义一个指向struct student的结构体指针函数*insert()用来添加考生信息.
{
    cout<<"\t----------------<<请输入新增学生成绩信息>>----------------\n"<<endl;
    p1=(student *)malloc(LEN);  //使p1指向插入的新结点
    cout<<" 准考证号(8位):";
    cin>>p1->id; //将输入的准考证号存放到p1所指结构体的数组id中
    cout<<" 姓名:";
    cin>>p1->name; //将输入的姓名存放到结构体名为p1的数组name中
    cout<<" 性别:";
    cin>>p1->sex;
    cout<<" 数学成绩:";
    cin>>p1->score[0];//将输入的数学成绩存放到p1所指结构体的数组score中
    cout<<" 物理成绩:";
    cin>>p1->score[1];//将输入的物理成绩存放到p1所指结构体的数组score中
    cout<<" 英语成绩:";
    cin>>p1->score[2];//将输入的英语成绩存放到p1所指结构体的数组score中
    cout<<" C语言成绩:";
    cin>>p1->score[3];//将输入的C语言成绩存放到p1所指结构体的数组score中
    p1->total=p1->score[0]+p1->score[1]+p1->score[2]+p1->score[3];//计算总分 
    p2=head;//将头指针赋给p2
    if(head==NULL) //若没调用次函数以前的头指针head为空
{
  head=p1;p1->next=NULL;
}//则将p1赋给头指针head并将p1所指结构体成员指针next赋空值
    else 
{
  while((p1->id>p2->id)&&(p2->next!=NULL))
  {
   p3=p2;//p3指向原p2指向的结点
            p2=p2->next;
  }//p2后移一个结点
  if(p1->id<=p2->id)
  {
   if(head==p2)
   {
    p1->next=head;
    head=p1;
   }   //插入到第一个结点之前
   else 
   {
    p3->next=p1;
    p1->next=p2;
   }        //插入到p3所指结点之后
  }
  else
  {
   p2->next=p1;
   p1->next=NULL;
  }            //插入到尾结点之后
}
n++;//将学生人数加1
    cout<<"\t----------------<<你输入的学生信息已经成功插入>>----------------"<<endl;
return (head);
}
//------------>删除函数
student *Information::cancel(student *head,long int num)//定义一个指向struct student的结构体指针函数*delete()用来删除考生信息.
{  
  
    if(head==NULL)//若调用次函数以前的头指针head为空
{  
     return(head);
  }

 2006-12-20 15:52
	    2006-12-20 15:52