栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++实现简单的信息管理系统

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++实现简单的信息管理系统

本文为大家分享C++实现简单的信息管理系统,小编之前在学习的时候也要做一些管理系统,在网上查了许多资料,现在我把资料分享给大家,希望能够帮助到大家。

#include 
#include 
#include "file.h"
 
 
 
void savaList(Node *head)
{
 FILE *fp=fopen("data\data.txt" ,"w") ;
 Node *p ;
 for(p=head->next;p;p=p->next)
 {
   fwrite(&(p->data),sizeof(students),1,fp) ;
 }
 fclose(fp) ;
 
}
 
 
 
void duquLisr(Node *head)
{
 FILE *fp=fopen("data\data.txt" ,"r") ;
 students e ;
  while( fread(&e,sizeof(students) ,1,fp ) )
  {
   insertList(head,e) ;
  }
  fclose(fp) ;
 
}
 
 
 
 
#include 
#include 
#include 
#include "goods.h"
 
  
students lurushuju()
{
 students e ;
 
 
 printf("请输入学生的姓名 ") ;
 scanf("%s",e.name);
 
 printf("请输入学生的电话 ") ;
 scanf("%s",e.phone) ;
 
 printf("请输入学生的街道 ") ;
 scanf("%s",e.street) ;
 
 printf("请输入学生的城市信息 ") ;
 scanf("%s",e.city) ;
 
 printf("请输入学生的邮编 ") ;
 scanf("%s",e.youb) ;
 
 
 return e ;
 
}
void shuchushuju(students e)
{
 printf("%15s%15s%15s%15s%15sn" , e.name ,e.phone,e.street,e.city,e.youb) ;
 
}
void xiugaishuju(students *e) 
{
 int score ;
 int count=1 ;
 printf("请输入想要修改的数据类型n") ;
 do
 {
 printf("1.姓名;2.电话;3.街道信息;4.城市信息;5.邮编;6.退出n");
 scanf("%d",&score) ;
 switch(score)
 {
 case 1:
  scanf("%s",e->name);
  break ;
 case 2:
  scanf("%s",e->phone) ;
  break;
 case 3:
  scanf("%s",e->street) ;
  break ;
 case 4:
  scanf("%s",e->city) ;
  break ;
 case 5:
  scanf("%s",e->youb) ;
  break ;
 default:
  count=0;
 }
 }while(count);
 
}
 
 
 
 
#include 
#include 
#include "list.h"
#include "goods.h"
 
void creatList(Node *head,int n)
{
 int i ;
 students p ;
 for(i=1; i<=n ; i++)
 {
  p=lurushuju() ;
  insertList(head,p) ;
 }
 
}
void insertList(Node *head,students e) 
{
 Node *p;
 Node *q;
 q=(Node*)malloc(sizeof(Node));
 q->data=e;
 for(p=head; p->next && strcmp( (p->next)->data.name,e.name)<0 ;p=p->next ) ;
 q->next=p->next;
 p->next=q;
}
 
int delList(Node *head,char e[])
{
 Node *p;
 for(p=head; p->next && strcmp(e,p->next->data.name) ;p=p->next) ;
 if(p->next ==0)
 {
  return 0 ;
 }
 else
 {
  Node *t;
  t=p->next;
  p->next=t->next;
  free(t);
  return 1 ;
 }
 
}
 
 
Node *searchList(Node *head,char e[])
{
 Node *p;
 for(p=head; p && strcmp(e,p->data.name) ; p=p->next ) ;
 return p ;
}
 
 
void disputList(Node *head)
{
 Node *p;
 for(p=head->next;p;p=p->next)
 shuchushuju(p->data);
 
 
}
 
void changeList(Node *head ,char e[])  
{
 Node *p ;
 p=searchList(head,e) ;
 if(!p)
 {
  printf("errorn");
 }
 else
 {
  xiugaishuju(&(p->data)) ;
 
 }
 
}
void destroy(Node *head)
{
 Node *p;
 for(p=head;p;p=p->next)
  free(p);
}
 
 
#include 
#include 
#include 
#include "list.h"
#include "goods.h"
 
void mainmenu(Node *head)
{
 int scored ;
 int count=1 ;
 char e[100] ;
 int n;
 students p;
 do
 {
 printf("================****学生信息管理系统(公测版by李远航)****=====n") ;
 printf("==========================开始===============================n");
 printf("==1.录入数据 2.修改数据 3.显示数据 4.删除数据 5.插入数据=n") ;
 printf("=======7.读取数据========6.存盘退出=======8.退出=============n") ;
 printf("=======================**********============================n") ;
  printf("请输入你想要做的事n") ;
  scanf("%d",&scored);
 switch(scored)
 {
 case 1:
  printf("请输入你大约想保存的学生n");
  scanf("%d",&n);
  creatList(head,n);
  break ;
 case 2:
  printf("请输入待改学生的姓名n") ;
  scanf("%s",e);
  changeList(head , e) ;
  break ;
 case 3:
  printf("   姓名   电话  街道信息   城市信息  邮件信息 n") ;
  disputList(head) ;
  break ;
 case 4:
  printf("请输入待删学生的姓名n");
  scanf("%s",e);
  n=delList(head, e) ;
  if(n)
  {
   printf("删除成功n");
  }
  else
  {
   printf("errorn") ;
  }
  break ;
 case 5:
  printf("请输入你想插入的信息n");
  p=lurushuju();
  insertList(head, p);
  break ;
 case 6:
  savaList(head);
  count=0;
  break ;
 case 7:
  duquLisr(head);
  break ;
 default :
  count=0;
 }
 system("pause") ;
 system("cls") ;
 
 }while(count);
 printf("nnnn感谢您对本系统的支持,如果您在使用过程中遇到bug,请发送邮件到1277171561@qq.comnnnnnnn") ;
 
 
}
 
 
 
int main()
{
 Node *head=(Node*)malloc(sizeof(Node));
 head->next=NULL ;
 mainmenu(head) ;
 destroy(head) ;
 return 0;
}
 
 
#ifndef FILE_H_INCLUDED
#define FILE_H_INCLUDED
#include "list.h"
 
void savaList(Node *head);
void duquLisr(Node *head);
 
 
 
#endif // FILE_H_INCLUDED
 
 
 
#ifndef GOODS_H_INCLUDED
#define GOODS_H_INCLUDED
 
typedef struct students 
{
 char name[100] ;
 char phone[100] ;
 char street[100] ;
 char city[100] ;
 char youb[100] ;
 
}students;
 
students lurushuju();
void shuchushuju(students e);
void xiugaishuju(students *e);
 
 
 
 
 
#endif // GOODS_H_INCLUDED
 
 
 
 
#ifndef LIST_H_INCLUDED
#define LIST_H_INCLUDED
#include "goods.h"
 
typedef struct Node 
{
 students data ;
 struct Node *next ;
}Node ;
 
void creatList(Node *head,int n);
void insertList(Node *head,students e) ;
int delList(Node *head,char e[]) ;
Node *searchList(Node *head,char e[]) ; 
void disputList(Node *head);
void changeList(Node *head ,char e[]) ;
void destroy(Node *head) ;
 
 
 
 
 
#endif // LIST_H_INCLUDED

以上就是C++信息管理系统的关键代码,供大家参考,下面再为大家分享一些其他管理系统:

C++实现简单的图书管理系统

C++实现简单的职工信息管理系统

C++基础学生管理系统

更多学习资料请关注专题《管理系统开发》。

以上就是本文的全部内容,希望对大家的学习有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/64445.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号