C++實(shí)現(xiàn)簡(jiǎn)單的信息管理系統(tǒng)
本文為大家分享C++實(shí)現(xiàn)簡(jiǎn)單的信息管理系統(tǒng),小編之前在學(xué)習(xí)的時(shí)候也要做一些管理系統(tǒng),在網(wǎng)上查了許多資料,現(xiàn)在我把資料分享給大家,希望能夠幫助到大家。
#include <stdio.h>
#include <stdlib.h>
#include "file.h"
void savaList(Node *head)/**把用戶(hù)錄入的數(shù)據(jù)存儲(chǔ)到文件里面去方便下次讀取*/
{
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)/**讀取用戶(hù)之前所錄入的數(shù)據(jù) */
{
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"
/**錄入數(shù)據(jù),函數(shù)目的返回一個(gè)goods類(lèi)型的值*/ /** char name[M] ;
char phone[M] ;
char street[M] ;
char city[M] ;
char youb[M] ; */
students lurushuju()
{
students e ;
printf("請(qǐng)輸入學(xué)生的姓名 ") ;
scanf("%s",e.name);
printf("請(qǐng)輸入學(xué)生的電話 ") ;
scanf("%s",e.phone) ;
printf("請(qǐng)輸入學(xué)生的街道 ") ;
scanf("%s",e.street) ;
printf("請(qǐng)輸入學(xué)生的城市信息 ") ;
scanf("%s",e.city) ;
printf("請(qǐng)輸入學(xué)生的郵編 ") ;
scanf("%s",e.youb) ;
return e ;
}
void shuchushuju(students e)/**依次輸出數(shù)據(jù)e*/
{
printf("%15s%15s%15s%15s%15s\n" , e.name ,e.phone,e.street,e.city,e.youb) ;
}
void xiugaishuju(students *e)/**根據(jù)地址修改數(shù)據(jù)e里面的個(gè)別數(shù)據(jù)*/ /**通過(guò)選擇序號(hào)選擇想要修改的數(shù)據(jù)*/
{
int score ;
int count=1 ;
printf("請(qǐng)輸入想要修改的數(shù)據(jù)類(lèi)型\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)/**創(chuàng)建一個(gè)長(zhǎng)度為n的鏈表*/
{
int i ;
students p ;
for(i=1; i<=n ; i++)
{
p=lurushuju() ;
insertList(head,p) ;
}
}
void insertList(Node *head,students e) /**把e中的某一個(gè)值以一定的順序插入到以head為頭節(jié)點(diǎn)的鏈表上面去*/
{
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的一項(xiàng)刪除,先找找到刪除成功就返回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[])/**在鏈表中查找名字這一項(xiàng)找到返回這個(gè)節(jié)點(diǎn)的地址 否者返回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[]) /**修改鏈表中某一個(gè)節(jié)點(diǎn)的data值*/ /**該系統(tǒng)只能通過(guò)姓名查找 后續(xù)在完善*/
{
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("================****學(xué)生信息管理系統(tǒng)(公測(cè)版by李遠(yuǎn)航)****=====\n") ;
printf("==========================開(kāi)始===============================\n");
printf("==1.錄入數(shù)據(jù) 2.修改數(shù)據(jù) 3.顯示數(shù)據(jù) 4.刪除數(shù)據(jù) 5.插入數(shù)據(jù)=\n") ;
printf("=======7.讀取數(shù)據(jù)========6.存盤(pán)退出=======8.退出=============\n") ;
printf("=======================**********============================\n") ;
printf("請(qǐng)輸入你想要做的事\n") ;
scanf("%d",&scored);
switch(scored)
{
case 1:
printf("請(qǐng)輸入你大約想保存的學(xué)生\n");
scanf("%d",&n);
creatList(head,n);
break ;
case 2:
printf("請(qǐng)輸入待改學(xué)生的姓名\n") ;
scanf("%s",e);
changeList(head , e) ;
break ;
case 3:
printf(" 姓名 電話 街道信息 城市信息 郵件信息 \n") ;
disputList(head) ;
break ;
case 4:
printf("請(qǐng)輸入待刪學(xué)生的姓名\n");
scanf("%s",e);
n=delList(head, e) ;
if(n)
{
printf("刪除成功\n");
}
else
{
printf("error\n") ;
}
break ;
case 5:
printf("請(qǐng)輸入你想插入的信息\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感謝您對(duì)本系統(tǒng)的支持,如果您在使用過(guò)程中遇到bug,請(qǐng)發(fā)送郵件到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);/**把用戶(hù)錄入的數(shù)據(jù)存儲(chǔ)到文件里面去方便下次讀取*/
void duquLisr(Node *head);/**讀取用戶(hù)之前所錄入的數(shù)據(jù) */
#endif // FILE_H_INCLUDED
#ifndef GOODS_H_INCLUDED
#define GOODS_H_INCLUDED
typedef struct students /*定義學(xué)生信息*/
{
char name[100] ;
char phone[100] ;
char street[100] ;
char city[100] ;
char youb[100] ;
}students;
students lurushuju();/**錄入數(shù)據(jù),函數(shù)目的返回一個(gè)goods類(lèi)型的值*/
void shuchushuju(students e);/**依次輸出數(shù)據(jù)e*/
void xiugaishuju(students *e);/**根據(jù)地址修改數(shù)據(jù)e里面的個(gè)別數(shù)據(jù)*/
#endif // GOODS_H_INCLUDED
#ifndef LIST_H_INCLUDED
#define LIST_H_INCLUDED
#include "goods.h"
typedef struct Node /**鏈表結(jié)構(gòu)體*/
{
students data ;
struct Node *next ;
}Node ;
void creatList(Node *head,int n);/**創(chuàng)建一個(gè)長(zhǎng)度為n的鏈表*/
void insertList(Node *head,students e) ;/**把e中的某一個(gè)值以一定的順序插入到以head為頭節(jié)點(diǎn)的鏈表上面去*/
int delList(Node *head,char e[]) ;/**把鏈表姓名為e的一項(xiàng)刪除,先找找到刪除成功就返回1,否者返回0*/
Node *searchList(Node *head,char e[]) ; /**在鏈表中查找名字這一項(xiàng)*/
void disputList(Node *head);/**依次順序輸出head鏈表*/
void changeList(Node *head ,char e[]) ;/**修改鏈表中某一個(gè)節(jié)點(diǎn)的data值 */
void destroy(Node *head) ;/**摧毀一起鏈表數(shù)據(jù)*/
#endif // LIST_H_INCLUDED
以上就是C++信息管理系統(tǒng)的關(guān)鍵代碼,供大家參考,下面再為大家分享一些其他管理系統(tǒng):
C++實(shí)現(xiàn)簡(jiǎn)單的圖書(shū)管理系統(tǒng)
C++實(shí)現(xiàn)簡(jiǎn)單的職工信息管理系統(tǒng)
更多學(xué)習(xí)資料請(qǐng)關(guān)注專(zhuān)題《管理系統(tǒng)開(kāi)發(fā)》。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。
相關(guān)文章
opengl實(shí)現(xiàn)任意兩點(diǎn)間畫(huà)圓柱體
這篇文章主要為大家詳細(xì)介紹了opengl實(shí)現(xiàn)任意兩點(diǎn)間畫(huà)圓柱體,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06
C語(yǔ)言實(shí)現(xiàn)信號(hào)槽的項(xiàng)目實(shí)踐
信號(hào)槽是觀察者模式的一種實(shí)現(xiàn),一個(gè)信號(hào)就是一個(gè)能夠被觀察的事件,本文主要介紹了C語(yǔ)言實(shí)現(xiàn)信號(hào)槽的項(xiàng)目實(shí)踐模具有一定的參考價(jià)值,感興趣的可以了解一下2024-04-04
C語(yǔ)言的隨機(jī)數(shù)rand()函數(shù)詳解
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言的隨機(jī)數(shù)rand()函數(shù),使用數(shù)據(jù)庫(kù),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2022-02-02
C++實(shí)現(xiàn)飛機(jī)大戰(zhàn)游戲
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)飛機(jī)大戰(zhàn)游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06

