C++完成簡略的信息治理體系。本站提示廣大學習愛好者:(C++完成簡略的信息治理體系)文章只能為提供參考,不一定能成為您想要的結果。以下是C++完成簡略的信息治理體系正文
本文為年夜家分享C++完成簡略的信息治理體系,小編之前在進修的時刻也要做一些治理體系,在網上查了很多材料,如今我把材料分享給年夜家,願望可以或許贊助到年夜家。
#include <stdio.h>
#include <stdlib.h>
#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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "goods.h"
/**錄入數據,函數量的前往一個goods類型的值*/ /** char name[M] ;
char phone[M] ;
char street[M] ;
char city[M] ;
char youb[M] ; */
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)/**順次輸入數據e*/
{
printf("%15s%15s%15s%15s%15s\n" , e.name ,e.phone,e.street,e.city,e.youb) ;
}
void xiugaishuju(students *e)/**依據地址修正數據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 <stdio.h>
#include <string.h>
#include "list.h"
#include "goods.h"
void creatList(Node *head,int n)/**創立一個長度為n的鏈表*/
{
int i ;
students p ;
for(i=1; i<=n ; i++)
{
p=lurushuju() ;
insertList(head,p) ;
}
}
void insertList(Node *head,students e) /**把e中的某一個值以必定的次序拔出到以head為頭節點的鏈表下面去*/
{
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[])/**把鏈表姓名為e的一項刪除,先找找到刪除勝利就前往1,否者前往0*/
{
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[])/**在鏈表中查找名字這一項找到前往這個節點的地址 否者前往null*/
{
Node *p;
for(p=head; p && strcmp(e,p->data.name) ; p=p->next ) ;
return p ;
}
void disputList(Node *head)/**順次次序輸入head鏈表*/
{
Node *p;
for(p=head->next;p;p=p->next)
shuchushuju(p->data);
}
void changeList(Node *head ,char e[]) /**修正鏈表中某一個節點的data值*/ /**該體系只能經由過程姓名查找 後續在完美*/
{
Node *p ;
p=searchList(head,e) ;
if(!p)
{
printf("error\n");
}
else
{
xiugaishuju(&(p->data)) ;
}
}
void destroy(Node *head)
{
Node *p;
for(p=head;p;p=p->next)
free(p);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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("error\n") ;
}
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("\n\n\n\n感激您對本體系的支撐,假如您在應用進程中碰到bug,請發送郵件到1277171561@qq.com\n\n\n\n\n\n\n") ;
}
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();/**錄入數據,函數量的前往一個goods類型的值*/
void shuchushuju(students e);/**順次輸入數據e*/
void xiugaishuju(students *e);/**依據地址修正數據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);/**創立一個長度為n的鏈表*/
void insertList(Node *head,students e) ;/**把e中的某一個值以必定的次序拔出到以head為頭節點的鏈表下面去*/
int delList(Node *head,char e[]) ;/**把鏈表姓名為e的一項刪除,先找找到刪除勝利就前往1,否者前往0*/
Node *searchList(Node *head,char e[]) ; /**在鏈表中查找名字這一項*/
void disputList(Node *head);/**順次次序輸入head鏈表*/
void changeList(Node *head ,char e[]) ;/**修正鏈表中某一個節點的data值 */
void destroy(Node *head) ;/**摧毀一路鏈表數據*/
#endif // LIST_H_INCLUDED
以上就是C++信息治理體系的症結代碼,供年夜家參考,上面再為年夜家分享一些其他治理體系:
C++完成簡略的圖書治理體系
C++完成簡略的職工信息治理體系
C++基本先生治理體系
以上就是本文的全體內容,願望對年夜家的進修有所贊助。