跪求c语言程序设计报告,学生学籍管理系统

2025-03-22 23:02:48
推荐回答(3个)
回答1:

  试试看
  #include
  #include
  #include
  #include
  using namespace std;
  #define NULL 0
  class student
  {
  public:
  long num;
  string name;
  string dizhi,dihua,banji;
  student *next;
  };
  int n; //链结点的个数
  student *head,*stu;
  /////////////////////////////////////////////////////////////////////
  student *creat(void) //创建动态链表 返回以各指向链表头的指针
  { student *head;
  student *p1,*p2;
  n=0;
  p1=p2=new student; //开辟新单元,用P1 P2指向
  cout<<"按顺序输入学生的学号,姓名,地址,电话,班级,输入0 * * * *就停止录入(*为任意字符)" <  cin>>p1->num>>p1->name>>p1->dizhi>>p1->dihua>>p1->banji;
  head=NULL;
  while(p1->num!=0) //循环输入的作用
  {n=n+1;
  if(n==1)head=p1;
  else p2->next=p1;
  p2=p1;
  p1=new student; //开辟新单元,
  cin>>p1->num>>p1->name>>p1->dizhi>>p1->dihua>>p1->banji; //输入数据
  }
  p2->next=NULL; //p2指向最后
  return(head);
  }

  ///////////////////////////////////////////作为二进制储存和读出二进制文件
  void write_read()
  {student *p;
  student stud[100];
  n=0;
  for(p=head;p!=NULL;p=p->next)
  { stud[n].dizhi=p->dizhi;
  stud[n].dihua=p->dihua;
  stud[n].banji=p->banji;
  stud[n].name=p->name;
  stud[n].num=p->num;
  n++;
  }

  ofstream outfile("student.dat",ios::binary);
  if(!outfile)
  { cerr<<"open error...."<  abort();
  }
  for(int i=0;i
  outfile.write((char*)&stud[i],sizeof(stud[i]));
  outfile.close();
  ifstream infile("student.dat",ios::binary);
  if(!infile)
  { cerr<<"open error...."<  abort();
  }

  for(int j=0;j  infile.read((char*)&stud[i],sizeof(stud[i]));
  infile.close();
  for(int k=0;k  { cout<<"姓名: "<  cout<<"学号: "<  cout<<"地址 : "<  cout<<"电话: "<  cout<<"班级: "<  }

  }
  ///////////////////////////////////////////////////////////////图形的输出
  void exit()
  {

  cout<<" ┃ \n"
  " ┃ \n"
  " ┏━━━━┻━━━━┓ \n"
  " ┃ ┃ \n"
  " ┏━━━━┻━━━━━━━━━┻━━━━┓\n"
  " ┃ ^^^^^谢谢使用^^^^^^^ ┃\n"
  " ┃ ┃\n"
  " ┃ 偷得浮生半日闲 ┃\n"
  " ┃ ┃\n"
  " ┃ ┃\n"
  " ┗━━━━━━━━━━━━━━━━━━━┛\n";

  }

  /////////////////////////////////////////////////////////////////////////////////////////////////////
  void print(student *head) //输出链表
  {student *p;
  cout<<" 学生信息表 "<  p=head;
  if(head!=NULL)
  cout<<" "<  cout<<" 学号 姓名 地址 电话 班级 "<  cout<<" "<  if(head!=NULL)
  do
  { cout<num
  <name
  <dizhi
  <dihua
  <banji
  <  cout<<" "<  p=p->next;
  }while(p!=NULL);

  }
  ////////////////////////////////////////////////////////////////////////删除链表

  student *del(student *head,long num)
  {student *p1,*p2;
  if(head==NULL)
  {cout<<"此为空表"<  p1=head;
  while(num!=p1->num && p1->next!=NULL)
  {p2=p1;p1=p1->next;}
  if(num==p1->num)
  {if(p1==head)head=p1->next;
  else p2->next=p1->next;
  cout<<"删除"<  n=n-1;}

  else
  cout<<"没有该同学数据!"<  return(head);
  cout<  }
  ///////////////////////////////////////////////////////////////////////////// 链表的舔加

  student *insert(student *head,student *stud)
  {student *p0,*p1,*p2;
  p1=head; //P1指向第一个节点
  p0=stud; //要插入的节点
  if(head==NULL)
  {head=p0;p0->next=NULL;} //是P0指向节点作为头
  else
  {while((p0->num>p1->num)&&(p1->next!=NULL))
  {p2=p1; p1=p1->next;}
  if(p0->num<=p1->num)
  {if(head==p1)head=p0;
  else
  p2->next=p0;
  p0->next=p1;
  }

  else
  {p1->next=p0;p0->next=NULL;} //差 如节点之后
  }
  n=n+1; //节点+1
  return(head);
  cout<  }
  ///////////////////////////////////////////////////////////////////////查找学生
  void find()
  {student *p;
  int a;
  cout<<"请输入想要找的学生的学号"<  cin>>a;
  for(p=head;p!=NULL;p=p->next)
  { if(a==p->num)
  { cout<<" "<  cout<<" 学号 姓名 地址 地话 班级 "<  cout<<" "<  cout<num
  <name
  <dizhi
  <dihua
  <banji
  <  cout<<" "<  break;
  }
  else
  continue;
  }
  }
  ///////////////////////////////////////////////////////////////////////////////删除和添加的链表的多次执行的实现
  void list()
  { int a;
  long del_num;
  student *creat(void);//输入学生数据
  student *cunt_put(student *);
  student *del(student *,long);
  student *insert(student *,student *);
  void print(student *);
  cout<<" "<  head=creat();
  print(head); //输出全部结点
  cout<<"如果要删除学生资料请输入1,如果需要添加请输入2"<  cin>>a;
  if(a==1)
  { cout<<"输入要删除学号"<  cin>>del_num;
  while(del_num!=0 )
  { head=del(head,del_num);
  print(head); //调用输出函数
  cout<<"是否继续删除:是(输入学号),不是(输入0)"<  cin>>del_num;
  }

  }

  cout<<",往下执行就按任意数字"<  cin>>a;
  if (a==2) //操作选择
  { cout<<"输入要添加的就输入学号"<  stu=new student; //开创新的空间
  cin>>stu->num>>stu->name>>stu->dizhi>>stu->dihua>>stu->banji; //输入数据
  while(stu->num!=0) //可以循环删除,删除多个
  { head=insert(head,stu); //调用添加函数
  print(head); //调用输出函数
  cout<<"如果需要添加请输入学号,无需添加输入0 * * * *就停止录入(*为任意字符)"<  stu=new student;
  cin>>stu->num>>stu->name>>stu->dizhi>>stu->dihua>>stu->banji;
  }
  }
  cout<  }

  /////////////////////////////////////////////////////////////////////////调用各个函数
  void swich()
  { int a;
  list();//删除和添加调用

  cout<<"退出软件输入9 直接查看学生资料输入10"<  cin>>a;
  if(a==9)
  exit();
  if(a=10)
  { for(int u=0;;u++)
  {
  cout<<" 0按学号查某个学生的数据 1查看成绩表 3退出系统且读取二进制文件 "<  int t;
  cin>>t;

  if(t==1)
  { print(head);continue;
  }
  if(t==3)
  { exit();
  break;
  }
  if(t==0)
  { find();continue;
  }

  }
  }
  cout<<"读取二进制文件如下"<  write_read();
  }
  ////////////////////////////////////////////////////////密码实现
  void mima()
  { int n,m=1988825;
  for(int j=0;;j++)
  {
  cout<<"这是我的地盘,请输入密码:"<  cin>>n;

  if(m==n)
  { cout<<"恭喜你猜对了!!!"<  swich();
  break;
  }
  else
  {
  cout<<"内有怪物,生人勿进!"<  continue;
  }
  }
  }
  //////////////////////////////////////////////////主函数
  int main()
  { mima();
  return 0;
  }

回答2:

这是跟简单的程序,我想你们学校有计算机老师吧,那么让懂计算机的几分钟就能写好的程序。

回答3:

这个很多类似的啊,就像我们写单片机报告一样