• 大小: 94KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-26
  • 语言: C/C++
  • 标签: C  C++  

资源简介

南京邮电大学课程设计,内含详细的源码和试验报告!

资源截图

代码片段和文件信息

#include
#include
#include
#include 
class Student{
private:
  char StuNumber[10];
  char Sex;
  int Height;
  int Weight;
public:
  Student()
  {
   cout<<“Student constructing...“<  }
  ~Student()
  {
   cout<<“Student Destructing...“<  }
  friend void Input(fstreamStudent *);
  friend void Search(fstreamStudent *);
  friend void Search1(fstreamStudent *);
  friend void MaxandMinHeightSearch(fstreamStudent *);
  friend void MaxandMinWeightSearch(fstreamStudent *);
  friend void PercentHeightandWeight(fstreamStudent *);
  friend void Health(fstreamStudent *);
  friend ostream &operator<<(ostream &outStudent &stu);
  friend istream &operator>>(istream &inStudent &stu);
};
//重载运算符<<
ostream &operator<<(ostream &outStudent &stu)
{
out<  return out;
}
//重载运算符>>以方便下面整体输出
istream &operator>>(istream &inStudent &stu)
{
  in>>stu.StuNumber>>stu.Sex>>stu.Height>>stu.Weight;
  return in;
}
//输入学生信息的函数
void Input(fstream opStudent *p)
{
  int numcounter=1;
  cout<<“请输入学生总数:“;
  cin>>num;
  cout<<“请按以下格式录入学生信息:“<  cout<<“  学号   性别   身高   体重“<  cout<<“---------------------------------------“<  while(counter<=num)
  {
   cin>>*p;
   op.write((char *) psizeof(Student));
   counter++;
  }
  cout<<“---------------------------------------“<}
//查询所有数据的函数
void Search(fstream opStudent *p)
{
  int flag=0;
  cout<<“---------------------------------------“<  while(op.read((char *) psizeof(Student)))
  {
   cout<<*p<  flag=1;
  }
  if(!flag)
  {
   cout<<“数据库中没有数据“<  }
  cout<<“---------------------------------------“<}
//按学号查询数据的函数
void Search1(fstream opStudent *p)
{
  char str[10];
  int flag=0;
  cout<<“---------------------------------------“<  cout<<“请输入需要查询的学生学号:“;
  cin>>str;
  while(op.read((char *) psizeof(Student)))
  {
   if(strcmp(strp->StuNumber)==0)
   {
    cout<<*p<    flag=1;
   }
  }
  if(!flag)
  {
   cout<<“对不起,没有符合您的要求的数据“<  }
  cout<<“---------------------------------------“<}
//按性别查询具有最大身高、最小身高的学生的情况数据的函数
void MaxandMinHeightSearch(fstream opStudent *p)
{
  char a;
  int str[12];
  int i=0;
  int flag=0;
  cout<<“---------------------------------------“<  cout<<“请输入需要查询的最大身高、最小身高的学生的性别:“<  cin>>a;  
  cout<<“---------------------------------------“<  while(op.read((char *) psizeof(Student)))
  {
   if(a==p->Sex)
   {
    str[i]=p->Height;
    i++;
 flag=1;
   }
  }
  op.close();
   int max=str[0]min=str[0];
   for(int j=1;j   {
    if(str[j]>max)
    max=str[j];
   else if(str[j]    min=str[j];
  }
   op.open(“D:\\Shealth.txt“ios::in|ios::app);
while(op.read((char *) psizeof(Student)))
  {
  if(a==p->Sex)
  {
       if(max==p->Height)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        360  2007-06-07 16:17  程序设计B06021933\Shealth.txt

     文件        200  2007-06-07 16:35  程序设计B06021933\wrong.txt

     文件       9459  2007-06-07 16:32  程序设计B06021933\学生健康状况调查系统-B06021933.cpp

     文件     229448  2007-06-07 16:29  程序设计B06021933\学生健康状况调查系统-B06021933.exe

     文件     249856  2008-02-29 17:35  程序设计B06021933\程序设计报告—B06021933.doc

     目录          0  2008-03-08 15:12  程序设计B06021933

----------- ---------  ---------- -----  ----

               489323                    6


评论

共有 条评论