導航:首頁 > 源碼編譯 > 學生綜合管理系統源碼

學生綜合管理系統源碼

發布時間:2024-12-04 01:46:38

❶ 學生信息管理系統C++,使用Visual C++ 6.0編寫。源代碼參考

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedefstructlist{
structlist*next;
intnum;//學號
charname[30];//姓名
intage;//年齡
charsex;//性別
charaddr[50];//地址
charmobile[11];//號碼
intdepartment;//寢室號
}user;

voidinsert(user*h);
voidedit(user*h);
voiddel(user*h);
voidS_byName(user*h);
voidS_byNum(user*h);
voiddisplay(user*h);

intmain()
{
intflag;
user*head=(user*)malloc(sizeof(user));
head->next=NULL;
while(1)
{
printf("1、添加新用戶信息 ");
printf("2、修改用戶信息 ");
printf("3、刪除已有用戶信息 ");
printf("4、根據用戶名查詢信息 ");
printf("5、根據學號查詢信息 ");
printf("6、顯示全部用戶信息 "源咐兄);
printf("7、清屏 ");
printf("8、退出 ");
printf("請選擇:");
scanf("%d",&flag);
if(flag==1)
雹襲insert(head);
elseif(flag==2)
edit(head);
elseif(flag==3)
del(head);
elseif(flag==4)
S_byName(head);
elseif(flag==5)
S_byNum(head);
elseif(flag==6)
display(head);
elseif(flag==7)
system("clear");
elseif(flag==8)
return0;
else
printf("輸入有誤,請重新選擇! ");
}
}
voidinsert(user*h)
{
user*p=(user*)malloc(sizeof(user));
p->next=h->next;
h->next=p;
printf("請輸入新增用戶學號:"簡鍵);
scanf("%d",&p->num);
printf("請輸入新增用戶名稱(最多30個字):");
scanf("%s",p->name);
printf("請輸入新增用戶年齡:");
scanf("%d",&p->age);
printf("請輸入新增用戶性別:");
scanf("%c",&p->sex);
printf("請輸入新增用戶的家庭住址(最多50字):");
scanf("%s",p->addr);
printf("請輸入新增用戶的電話號碼(11位數):");
scanf("%s",p->mobile);
printf("請輸入新增用戶寢室號:");
scanf("%d",&p->department);
printf("新用戶記錄成功添加:%d%s%d%c%s%s%d ",p->num,p->name,p->age,p->sex,p->addr,p->mobile,p->department);
}
voidedit(user*h)
{
intnum;
intflag=0;
user*lh=h->next;
printf("輸入要修改用戶的學號:");
scanf("%d",&num);
while(lh)
{
if(num==lh->num)
{
flag=1;
printf("請輸入新增用戶學號:");
scanf("%d",&lh->num);
printf("請輸入新增用戶名稱(最多30個字):");
scanf("%s",lh->name);
printf("請輸入新增用戶年齡:");
scanf("%d",&lh->age);
printf("請輸入新增用戶性別:");
scanf("%c",&lh->sex);
printf("請輸入新增用戶的家庭住址(最多50字):");
scanf("%s",lh->addr);
printf("請輸入新增用戶的電話號碼(11位數):");
scanf("%s",lh->mobile);
printf("請輸入新增用戶寢室號:");
scanf("%d",&lh->department);
printf("新用戶記錄成功添加:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
break;
}
lh=lh->next;
}
if(!flag)
printf("不存在這樣的用戶 ");
}
voidS_byName(user*h)
{
charname[30];
intflag=0;
user*lh=h->next;
printf("輸入要查找的用戶名稱:");
scanf("%s",name);
while(lh)
{
if(strcmp(name,lh->name)==0)
{
flag=1;
printf("用戶信息為:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
break;
}
lh=lh->next;
}
if(!flag)
printf("用戶名不存在 ");
}
voidS_byNum(user*h)
{
intnum;
intflag=0;
user*lh=h->next;
printf("輸入要查找的學號:");
scanf("%d",&num);
while(lh)
{
if(num==lh->num)
{
flag=1;
printf("用戶信息:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
break;
}
lh=lh->next;
}
if(!flag)
printf("找不到匹配的號碼 ");
}
voiddisplay(user*h)
{
user*lh=h->next;
inti=1;
while(lh)
{
printf("第%d條用戶信息:%d%s%d%c%s%s%d ",i,lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
lh=lh->next;
i++;
}
printf(" ");
}
voiddel(user*h)
{
intnum;
intflag=0;
user*lh=h;
printf("輸入要刪除的用戶學號:");
scanf("%d",&num);
while(lh->next)
{
if(num==lh->next->num)
{
flag=1;
printf("刪除用戶成功:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
lh->next=lh->next->next;
break;
}
lh=lh->next;
}
if(!flag)
printf("用戶名不存在 ");
}

❷ 急求C語言編寫的圖書管理系統源代碼,具體要求如下

/*這有個以前用過的程序,你可以自己改改使用,但是有些功
能好像有問題,會中斷運行。至於程序的縮進式格式就你自己
敲回車和退格解決吧,不然代碼看起來會很亂不好看。*/
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#define STACK_INIT_SIZE 10
#define OK 1
#define TRUE 1
#define FALSE 0
#define ERROR 0

struct student /*定義學生類型,用於存放借出的書籍*/
{
int carnum;
char lendbook[10];
}student[1000];

struct employ /*定義職工類型*/
{
int employnum;
char employname[15];
int employage;
char employsex[2];
char employleve[10];
long int employtage;
}employ[50];

struct book /*定義書的類型*/
{
int booknum;
char bookname[10];
char bookcreat[10];
int turefalse; /*用於借書和還書模塊判斷一本書是否借出的條件*/
}book[1000];

struct car /*借書卡的數據類型*/
{
int carnum;
char studentname[10];
int studentclass;
}car[100];

huanbook() /*還書函數*/
{
FILE *fp,*fp2; /*定義兩個文件指針,fp2用於修改數據時設立臨時文件用,防止數據遭破壞*/
int i,n;
int carnum;
char lendbook[10];
printf("請你輸入你的卡號\n");
scanf("%d",&carnum);
fp=fopen("car.txt","r"); /*讀取卡號記錄*/
for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++) /*for循環判斷卡號是否存在*/
{
if(car[i].carnum==carnum) /*卡號存在,進入下一循環*/
{
n=i;
fclose(fp);
printf("請輸入你要還的書的名字\n");
scanf("%s",lendbook);
fp=fopen("record.txt","r");
for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++) /*判斷是否借閱了輸入的書*/
{
if(strcmp(student[i].lendbook,lendbook)==0) /*借閱了該書,進入下一循環,否則出錯顯示*/
{
fclose(fp);
fp=fopen("record.txt","r");
fp2=fopen("bookl.txt","w");
for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++)
{
if(strcmp(student[i].lendbook,lendbook)==0)
{
continue; /*刪除還掉的書的借書記錄*/
}
fwrite(&student[i],sizeof(struct student),1,fp2); /*寫入原來沒還的書的記錄*/
}
fclose(fp);
fclose(fp2);
fp=fopen("record.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&student[i],sizeof(struct student),1,fp2)!=0;i++)
{
fwrite(&student[i],sizeof(struct student),1,fp); /*將借書記錄信息寫回*/
}
fclose(fp);
fclose(fp2);
fopen("bookl.txt","w"); /*清臨時文件的記錄*/
fclose(fp2);
fp=fopen("book.txt","r");
fp2=fopen("bookl.txt","w");
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++) /*將書的記錄寫入臨時文件,防止因為修改信息破壞以前的記錄*/
{
if(i==n)
{
book[i].turefalse=1;
fwrite(&book[i],sizeof(struct book),1,fp2); /*將還的書的原來狀態設為無人借閱的*/
continue;
}
fwrite(&book[i],sizeof(struct book),1,fp2);
}
fclose(fp);
fclose(fp2);
fp=fopen("book.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)
{
fwrite(&book[i],sizeof(struct book),1,fp); /*將臨時文件寫回*/
}
fclose(fp);
fclose(fp2);
fopen("bookl.txt","w"); /*清臨時文件*/
fclose(fp2);
printf("還書完畢,按任意鍵返回\n");
getch();
return 1;
}
}
printf("你沒有借這樣的書,任意鍵返回\n"); /*出錯提示*/
fclose(fp);
getch();
return 0;
}
}
printf("系統沒這樣的卡,和管理員聯系,按任意鍵返回\n"); /*出錯提示*/
fclose(fp);
getch();
}

findbook()
{
FILE *fp;
char bookname[10];
int ture,i;
fp=fopen("book.txt","r");
printf("請輸入你要查找的書名\n");
scanf("%s",bookname);
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{
if(strcmp(bookname,book[i].bookname)==0)
{
if(book[i].turefalse==1)
{
printf("這本書的詳細資料是:%d %s %s 此書現在無人借閱\n按任意鍵返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat);
}
else {printf("這本書已經有人借出\n");fclose(fp);return 0;}
fclose(fp);
return FALSE;
}
}
printf("沒有你要查詢的書籍\n");
fclose(fp);
return FALSE;
}

findbook1()
{
FILE *fp;
char bookcreat[10];
int ture,i;
fp=fopen("book.txt","r");
printf("請輸入你要查找的作者名\n");
scanf("%s",bookcreat);
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{
if(strcmp(bookcreat,book[i].bookcreat)==0)
{
if(book[i].turefalse==1)
{
printf("這本書的詳細資料是:%d %s %s 此書現在無人借閱\n按任意鍵返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat);
}
else {printf("這本書已經有人借出\n");fclose(fp);return 0;}
fclose(fp);
return FALSE;
}
}
printf("沒有你要查詢的書籍\n");
fclose(fp);
return FALSE;
}

lendcount()
{
FILE *fp;
int i,n=0;
fp=fopen("record.txt","r");
for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++)
{
printf("卡號:%d 借出的書籍:%s \n",student[i].carnum,student[i].lendbook);
n=n+1;
}
fclose(fp);
printf("目前共有%d本書借出\n",n);
printf("按任意鍵\n");
getch();
return n;
}

chabook()
{
char ch5;
do
{
printf("---------------歡迎進入圖書查詢系統!--------------\n");
printf(" 1:<按書名查找>\n");
printf(" 2:<按作者查找>\n");
printf(" 0:<返回>\n");
printf("請輸入0--2,其他輸入非法!\n");
scanf("%s",&ch5);
switch(ch5)
{
case '1':findbook();getch();break;
case '2':findbook1();getch();break;
case '0':break;
default:printf("無此操作\n");getch();break;
}
}while(ch5!='0');
return FALSE;
}

lendbook()
{
FILE *fp,*fp2;
int i,n;
int carnum;
printf("請你輸入你的卡號\n");
scanf("%d",&carnum);
fp=fopen("car.txt","r");
for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++)
{
if(car[i].carnum==carnum)
{
n=i;
fclose(fp);
printf("請輸入你要借閱的書的名字\n");
scanf("%s",student[n].lendbook);
fp=fopen("book.txt","r");
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{
if(strcmp(book[i].bookname,student[n].lendbook)==0)
{
if(book[i].turefalse==0) {printf("對不起,此書有人借出,請借其他書\n");fclose(fp);getch();return;}
else
fclose(fp);
fp=fopen("record.txt","a+");
student[n].carnum=carnum;
fwrite(&student[n],sizeof(struct student),1,fp);
fclose(fp);
fp=fopen("book.txt","r");
fp2=fopen("bookl.txt","w");
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{
if(strcmp(book[i].bookname,student[n].lendbook)==0)
{
book[i].turefalse=0;
fwrite(&book[i],sizeof(struct book),1,fp2);
continue;
}
fwrite(&book[i],sizeof(struct book),1,fp2);
}
fclose(fp);
fclose(fp2);
fp=fopen("book.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)
{
fwrite(&book[i],sizeof(struct book),1,fp);
}
fclose(fp);
fclose(fp2);
fopen("bookl.txt","w");
fclose(fp2);
printf("借書完畢,按任意鍵返回\n");
getch();
return;
}
}
printf("不存在這樣的書,任意鍵返回\n");
fclose(fp);
getch();
return;
}
}
printf("你的卡號不存在,請申請新卡,按任意鍵返回\n");
fclose(fp);
getch();
}

carcount()
{
FILE *fp;
int i,n=0;
fp=fopen("car.txt","r");
for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++)
{
printf("第%d張卡<卡號:%d 姓名:%s 班級:%d>\n",i+1,car[i].carnum,car[i].studentname,car[i].studentclass);
n=n+1;
}
fclose(fp);
printf("目前共有%d本書\n",n);
printf("按任意鍵\n");
getch();
}

delcar()
{
FILE *fp,*fp2;
int i;
int carnum;
char choice;
fp=fopen("car.txt","r");
fp2=fopen("bookl.txt","w");
printf("請輸入你要刪除的卡號\n");
printf("如果你輸入的卡號存在,系統自動刪除該信息!如果不存在,系統不做任何改動\n");
scanf("%d",&carnum);
for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++)
{
if(car[i].carnum!=carnum)
{
fwrite(&car[i],sizeof(struct car),1,fp2);
}
}
fclose(fp);
fclose(fp2);
printf("是否真的要刪除該卡?刪除後該書籍的所有信息將無法恢復《Y/N》\n");
scanf("%s",&choice);
if(choice=='y'||choice=='Y')
{
fp=fopen("car.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&car[i],sizeof(struct car),1,fp2)!=0;i++)
{
fwrite(&car[i],sizeof(struct car),1,fp);
}
fclose(fp);
fclose(fp2);
fp2=fopen("bookl.txt","w");
fclose(fp2);
printf("按任意鍵返回\n");
getch();
return;
}
else
{
printf("按任意鍵返回\n");
getch();
return;
}
}

addcar()
{
FILE *fp;
int i=0;
fp=fopen("car.txt","a+");
printf("請你輸入卡號\n");
scanf("%d",&car[i].carnum);
printf("請你輸入學生姓名\n");
scanf("%s",car[i].studentname);
printf("請你輸入班級\n");
scanf("%d",&car[i].studentclass);
fwrite(&car[i],sizeof(struct car),1,fp);
fclose(fp);
printf("輸入完畢,任意鍵返回\n");
getch();
}

changemploy()
{
FILE *fp,*fp2;
char employname[10],choice;
int i;
fp=fopen("employ.txt","r");
fp2=fopen("bookl.txt","w");
printf("請你輸入要修改的職工的名字\n");
scanf("%s",employname);
for(i=0;fread(&employ[i],sizeof(struct employ),1,fp)!=0;i++)
{
if(strcmp(employ[i].employname,employname)==0)
{
printf("你所要修改的職工的資料如下,請選擇你要修改的內容\n");
printf("<職工號:%d職工名:%s 年齡:%d 性別:%s 學歷:%s 工資:%d>\n",employ[i].employnum,employ[i].employname,employ[i].employage,employ[i].employsex,employ[i].employleve,employ[i].employtage);
printf("2:修改職工名\n");
printf("3:修改職工年齡\n");
printf("4:修改職工工資\n");
printf("5:修改職工學歷\n");
printf("請輸入1-5:");
scanf("%s",&choice);
switch(choice)
{
case '1':
{
printf("請輸入新的職工號\n");
scanf("%d",&employ[i].employnum);
fwrite(&employ[i],sizeof(struct employ),1,fp2);
}break;
case '2':
{
printf("請輸入新的職工姓名\n");
scanf("%s",employ[i].employname);
fwrite(&employ[i],sizeof(struct employ),1,fp2);
}break;
case '3':
{
printf("請輸入新的年齡\n");
scanf("%d",&employ[i].employage);
fwrite(&employ[i],sizeof(struct employ),1,fp2);
}break;
case '4':
{
printf("請輸入新的職工工資\n");
scanf("%d",&employ[i].employtage);
fwrite(&employ[i],sizeof(struct employ),1,fp2);
}break;
case '5':
{
printf("請輸入新的職工學歷\n");
scanf("%s",employ[i].employleve);
fwrite(&employ[i],sizeof(struct employ),1,fp2);
}
default:printf("沒有這樣的操作");break;
}
continue;
}
fwrite(&employ[i],sizeof(struct employ),1,fp2);
}
fclose(fp);
fclose(fp2);
fp=fopen("employ.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&employ[i],sizeof(struct employ),1,fp2)!=0;i++)
{
fwrite(&employ[i],sizeof(struct employ),1,fp);
}
fclose(fp);
fclose(fp2);
fp2=fopen("bookl.txt","w");
fclose(fp2);
printf("按任意鍵返回\n");
getchar();
return;
}

delemploy()
{
FILE *fp,*fp2;
int i;
char employname[10],choice;
fp=fopen("employ.txt","r");
fp2=fopen("bookl.txt","w");
printf("請輸入你要刪除的職工名\n");
printf("如果你輸入的職工存在,系統自動刪除該信息!如果不存在,系統不做任何改動\n");
scanf("%s",employname);
for(i=0;fread(&employ[i],sizeof(struct employ),1,fp)!=0;i++)
{
if(strcmp(employname,employ[i].employname)!=0)
{
fwrite(&employ[i],sizeof(struct employ),1,fp2);
}
}
fclose(fp);
fclose(fp2);
printf("是否真的要刪除該職工信息?刪除後的所有信息將無法恢復《Y/N》\n");
scanf("%s",&choice);
if(choice=='y'||choice=='Y')
{
fp=fopen("employ.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&employ[i],sizeof(struct employ),1,fp2)!=0;i++)
{
fwrite(&employ[i],sizeof(struct employ),1,fp);
}
fclose(fp);
fclose(fp2);
fp2=fopen("bookl.txt","w");
fclose(fp2);
printf("按任意鍵返回\n");
getch();
return TRUE;
}
else
{
printf("按任意鍵返回\n");
getch();
return FALSE;
}
}

employcount()
{
FILE *fp;
int i,n=0;
fp=fopen("employ.txt","r");
for(i=0;fread(&employ[i],sizeof(struct employ),1,fp)!=0;i++)
{
printf("第%d職工的信息如下:\n<職工號:%d 職工名:%s 年齡:%d 性別:%s 學歷:%s 工資:%d>\n",n+1,employ[i].employnum,employ[i].employname,employ[i].employage,employ[i].employsex,employ[i].employleve,employ[i].employtage);
n++;
}
fclose(fp);
printf("目前共有%d個職工\n",n);
printf("按任意鍵返回\n");
}

addemploy()
{
FILE *fp;
char choice='y';
int i=1;
fp=fopen("employ.txt","a+");
while(choice=='y'||choice=='Y')
{
printf("請你輸入職工號碼\n");
scanf("%d",&employ[i].employnum);
printf("請你輸入職工名\n");
scanf("%s",employ[i].employname);
printf("請輸入職工年齡\n");
scanf("%d",&employ[i].employage);
printf("請你輸入性別\n");
scanf("%s",employ[i].employsex);
printf("請你輸入職工的學歷水平\n");
scanf("%s",employ[i].employleve);
printf("請輸入職工的工資\n");
scanf("%d",&employ[i].employtage);
fwrite(&employ[i],sizeof(struct employ),1,fp);
printf("是否要輸入下個職工信息?\n");
scanf("%s",&choice);
}
printf("按任意鍵返回\n");
fclose(fp);
}

addbook()
{
FILE *fp;
int i=0;
char choice='y';
fp=fopen("book.txt","a+");
while(choice=='y'||choice=='Y')
{
printf("請你輸入第%d本書的序號\n",i+1);
scanf("%d",&book[i].booknum);
printf("請你輸入書名\n");
scanf("%s",book[i].bookname);
printf("請你輸入書的作者\n");
scanf("%s",book[i].bookcreat);
printf("請設為1或0,1代表書還沒人借,0表示書已經借出,設其他值,程序運行時無法得出正常結果\n");
printf("請你設定書的狀態\n");
scanf("%d",&book[i].turefalse);
fwrite(&book[i],sizeof(struct book),1,fp);
printf("是否要輸入下本書\n");
scanf("%s",&choice);
}
fclose(fp);
}

bookcount()
{
FILE *fp;
int i,n=0;
fp=fopen("book.txt","r");
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{
if(book[i].booknum!=0&&strlen(book[i].bookname)!=0&&strlen(book[i].bookcreat)!=0)
{
printf("第%d本書<序號:%d 書名:%s 作者:%s 狀態:%d>\n",i+1,book[i].booknum,book[i].bookname,book[i].bookcreat,book[i].turefalse);
n=n+1;
}
}
fclose(fp);
printf("目前共有%d本書\n",n);
printf("按任意鍵\n");
}

delbook()
{
FILE *fp,*fp2;
int i;
char bookname[10],choice;
fp=fopen("book.txt","r");
fp2=fopen("bookl.txt","w");
printf("請輸入你要刪除的書名\n");
printf("如果你輸入的書名存在,系統自動刪除該信息!如果不存在,系統不做任何改動\n");
scanf("%s",bookname);
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{
if(strcmp(bookname,book[i].bookname)!=0)
{
fwrite(&book[i],sizeof(struct book),1,fp2);
}
}
fclose(fp);
fclose(fp2);
printf("是否真的要刪除該書籍?刪除後該書籍的所有信息將無法恢復《Y/N》\n");
scanf("%s",&choice);
if(choice=='y'||choice=='Y')
{
fp=fopen("book.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)
{
fwrite(&book[i],sizeof(struct book),1,fp);
}
fclose(fp);
fclose(fp2);
fp2=fopen("bookl.txt","w");
fclose(fp2);
printf("按任意鍵返回\n");
getch();
return;
}
else
{
printf("按任意鍵返回\n");
getch();
return;
}
}

changebook()
{
FILE *fp,*fp2;
char bookname[10],choice;
int i;
fp=fopen("book.txt","r");
fp2=fopen("bookl.txt","w");
printf("請你輸入要修改的書籍的書字\n");
scanf("%s",bookname);
for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++)
{
if(strcmp(book[i].bookname,bookname)==0)
{
printf("你所要修改的書的資料如下,請選擇你要修改的內容\n");
printf("序號:〈%d〉 書名:〈%s〉 作者:〈%s〉 \n",book[i].booknum,book[i].bookname,book[i].bookcreat);
printf("1:修改書的序號\n");
printf("2:修改書名\n");
printf("3:修改作者\n");
printf("請輸入1-3:");
scanf("%s",&choice);
switch(choice)
{
case '1':
{
printf("請輸入新的序號\n");
scanf("%d",&book[i].booknum);
fwrite(&book[i],sizeof(struct book),1,fp2);
}break;
case '2':
{
printf("請輸入新的書名\n");
scanf("%s",book[i].bookname);
fwrite(&book[i],sizeof(struct book),1,fp2);
}break;
case '3':
{
printf("請輸入新的作者\n");
scanf("%s",book[i].bookcreat);
fwrite(&book[i],sizeof(struct book),1,fp2);
}break;
defaut:printf("沒有這樣的操作");break;
}
continue;
}
fwrite(&book[i],sizeof(struct book),1,fp2);
}
fclose(fp);
fclose(fp2);
fp=fopen("book.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++)
{
fwrite(&book[i],sizeof(struct book),1,fp);
}
fclose(fp2);
fp2=fopen("bookl.txt","w");
fclose(fp2);
printf("按任意鍵返回\n");
getchar();
return;
}
main()
{
char ch1,ch2,ch3,ch4,ch5;
do
{
printf("\t\t請你選擇操作類型:\n");
printf(" 1:<查閱圖書>\n");
printf(" 2:<借閱圖書>\n");
printf(" 3:<管理系統>\n");
printf(" 4:<還書>\n");
printf(" 0:<退出>\n");
printf("請輸入0--4\n");
scanf("%s",&ch1);
switch(ch1)
{
case '1':chabook();break;
case '2':lendbook();;break;
case '3':{
do
{
printf("---------------歡迎進入管理系統!--------------\n");
printf(" 1:<增加圖書>\n");
printf(" 2:<刪除圖書>\n");
printf(" 3:<修改圖書資料>\n");
printf(" 4:<書籍統計>\n");
printf(" 5:<職工管理系統>\n");
printf(" 6:<學生管理系統>\n");
printf(" 0:<返回>\n");
printf("請輸入0--6,其他輸入非法!\n");
scanf("%s",&ch2);
switch(ch2)
{
case '1':addbook();
break;
case '2':delbook();break;
case '3':changebook();break;
case '4':bookcount();getch();break;
case '5':{do
{
printf("---------------歡迎進入職工管理系統!--------------\n");
printf(" 1:<增加員工>\n");
printf(" 2:<刪除員工>\n");
printf(" 3:<修改員工資料>\n");
printf(" 4:<員工統計>\n");
printf(" 0:<返回>\n");
printf("請輸入0--4,其他輸入非法!\n");
scanf("%s",&ch3);
switch(ch3)
{
case '1':addemploy();getch();break;
case '2':delemploy();break;
case '3':changemploy();break;
case '4':employcount();getch();break;
case '0':break;
default:printf("無此操作\n");getch();break;
}
}while(ch3!='0');}break;
case '6':{
do
{
printf("---------------歡迎進入學生管理系統!--------------\n");
printf(" 1:<申請新卡>\n");
printf(" 2:<刪除卡號>\n");
printf(" 3:<借書統計>\n");
printf(" 4:<卡號統計>\n");
printf(" 0:<返回>\n");
printf("請輸入0--4,其他輸入非法!\n");
scanf("%s",&ch4);
switch(ch4)
{
case '1':addcar();break;
case '2':delcar();break;
case '3':lendcount();break;
case '4':carcount();break;
case '0':break;
default:printf("無此操作\n");getch();break;
}
}while(ch4!='0');}break;
case '0':break;
default:printf("無此操作\n");getch();break;
}
}while(ch2!='0');}break;
case '4':huanbook();break;
case '0':break;
default:printf("無此操作\n");getch();break;
}
}while(ch1!='0');
}

❸ 學生基本信息管理系統C++源代碼

#include<iostream>
#include<iomanip>
#include<string>

usingnamespacestd;

typedefstructstudent{
unsignedm_id;
stringm_name;
unsignedm_age;
stringm_sex;
stringm_address;
stringm_contact;
stringm_dormitory;
structstudent*m_next;
}student;

classCStudent{
private:
student*head;
public:
CStudent(){
head=newstudent;
head->m_id=0;
head->m_name="noname";
head->m_next=NULL;
}
~CStudent(){
student*p=head,*q;
while(p){
q=p;
p=q->m_next;
deleteq;
}
}
studentreaddata(intmodel);//model=1:不讀取學號,2:不讀取姓名,其他,讀取所有信息
voidentering();
boolinsert(conststudent&astu);
student*findid(unsignedid)const;
student*findname(conststring&name)const;
student*findsex(conststring&sex)const;
student*finddormitory(conststring&dormitory)const;
unsignedboys()const;
unsignedgirls()const;
unsignedheadcount()const;
booleraseid();
boolerasename();
boolmodifyid();
boolmodifyname();
voidShow()const;
voidquery()const;
voidfriendstatistics(constCStudent&aclss);
voidfrienderase(CStudent&aclss);
voidfriendmodify(CStudent&aclss);
};

stringreadstring(){
stringstr;
while(cin.get()!=' ');
cin>>str;
returnstr;
}

studentCStudent::readdata(intmodel){
studenttmp;
if(model!=1){cout<<"學號:";cin>>tmp.m_id;}
if(model!=2){cout<<"姓名:";tmp.m_name=readstring();}
cin>>tmp.m_age;
cout<<"性別:";
tmp.m_sex=readstring();
cout<<"住址:";
tmp.m_address=readstring();
cout<<"聯系方式:";
tmp.m_contact=readstring();
cout<<"寢室:";
tmp.m_dormitory=readstring();
returntmp;
}

voidCStudent::entering(){
studenttmp;
cout<<"學號(0toreturn):";
cin>>tmp.m_id;
while(tmp.m_id){
if(findid(tmp.m_id)==NULL){
cout<<"姓名:";
tmp.m_name=readstring();
cout<<"年齡:";
cin>>tmp.m_age;
cout<<"性別:";
tmp.m_sex=readstring();
cout<<"住址:";
tmp.m_address=readstring();
cout<<"聯系方式:";
tmp.m_contact=readstring();
cout<<"寢室:";
tmp.m_dormitory=readstring();
insert(tmp);
}
elsecout<<"重復的學號:"<<tmp.m_id<<endl;
cout<<"學號(0toreturn):";
cin>>tmp.m_id;
}
}

student*CStudent::findid(unsignedid)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_id==id)returnp;
returnNULL;
}

student*CStudent::findname(conststring&name)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_name==name)returnp;
returnNULL;
}


student*CStudent::findsex(conststring&sex)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_sex==sex)returnp;
returnNULL;
}

student*CStudent::finddormitory(conststring&dormitory)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_dormitory==dormitory)returnp;
returnNULL;
}

boolCStudent::insert(conststudent&astu){
student*newnode,*p=head;
if(p->m_next==NULL){
p->m_next=newstudent(astu);
p->m_next->m_next=NULL;
returntrue;
}
while(p->m_next){
if(p->m_next->m_id==astu.m_id){
cout<<"重復的學號,插入失敗! ";
returnfalse;
}
if(p->m_next->m_id>astu.m_id){
newnode=newstudent(astu);
newnode->m_next=p->m_next;
p->m_next=newnode;
returntrue;
}
p=p->m_next;
}
p->m_next=newstudent(astu);
p->m_next->m_next=NULL;
returntrue;
}

unsignedCStudent::boys()const{
unsignedcnt=0;
student*p;
for(p=head->m_next;p;p=p->m_next)
if(p->m_sex=="男")++cnt;
returncnt;
}

unsignedCStudent::girls()const{
unsignedcnt=0;
student*p;
for(p=head->m_next;p;p=p->m_next)
if(p->m_sex=="女")++cnt;
returncnt;
}

unsignedCStudent::headcount()const{
unsignedcnt=0;
student*p;
for(p=head->m_next;p;p=p->m_next,++cnt);
returncnt;
}

boolCStudent::eraseid(){
student*q,*p;
unsignedid;
cout<<"輸入要刪除的學號:";
cin>>id;
p=findid(id);
if(p==NULL){
cout<<"沒有找到學號是""<<id<<""的學生,刪除失敗! ";
returnfalse;
}
q=p->m_next;
p->m_next=q->m_next;
deleteq;
returntrue;
}
boolCStudent::erasename(){
student*q,*p;
stringname;
cout<<"輸入要刪除人的姓名:";
name=readstring();
p=findname(name);
if(p==NULL){
cout<<"沒有找到姓名是""<<name<<""的學生,刪除失敗! ";
returnfalse;
}
q=p->m_next;
p->m_next=q->m_next;
deleteq;
returntrue;
}

boolCStudent::modifyid(){
studenttmp,*p;
unsignedid;
cout<<"輸入要修改的學號:";
cin>>id;
p=findid(id);
if(p==NULL){
cout<<"沒有找到學號是""<<id<<""的學生,修改失敗! ";
returnfalse;
}
tmp=readdata(1);
tmp.m_id=id;
*p=tmp;
returntrue;
}

boolCStudent::modifyname(){
student*p,tmp;
stringname;
cout<<"輸入要修改人的姓名:";
name=readstring();
p=findname(name);
if(p==NULL){
cout<<"沒有找到姓名是""<<name<<""的學生,修改失敗! ";
returnfalse;
}
tmp=readdata(2);
tmp.m_name=name;
*p=tmp;
returntrue;
}

intmenu(){
intchoice;
do{
system("cls");
cout<<" **************************** ";
cout<<" *學生基本信息管理系統* ";
cout<<" *==========================* ";
cout<<" *1、錄入學生信息* ";
cout<<" *2、顯示學生信息* ";
cout<<" *3、查詢學生信息* ";
cout<<" *4、添加學生信息* ";
cout<<" *5、統計學生信息* ";
cout<<" *6、刪除學生信息* ";
cout<<" *7、修改學生信息* ";
cout<<" *0、退出管理系統* ";
cout<<" **************************** ";
cout<<" 請選擇:";
cin>>choice;
}while(choice<0||choice>7);
returnchoice;
}

voidshow(student*p){
cout<<p->m_id<<""<<p->m_name<<""<<p->m_age<<"";
cout<<p->m_sex<<""<<p->m_address<<"";
cout<<p->m_contact<<""<<p->m_dormitory<<endl;
}

voidCStudent::Show()const{
student*p;
cout<<"---------------------------------------------------------- ";
for(p=head->m_next;p;p=p->m_next)show(p);
cout<<"---------------------------------------------------------- ";
system("pause");
}

voidCStudent::query()const{
intselect;
unsignedid;
stringname;
student*p;
cout<<"1、按學號查詢 2、按姓名查詢 0、返回 ";
cin>>select;
switch(select){
case1:cout<<"請輸入學號:";cin>>id;
if(p=findid(id))show(p->m_next);
break;
case2:cout<<"請輸入姓名:";name=readstring();
if(p=findname(name))show(p->m_next);
break;
case0:return;
default:cout<<"選擇錯誤。 ";
}
system("pause");
}

voidstatistics(constCStudent&a){
unsignedtotal=a.headcount();
unsignedboys=a.boys();
unsignedgirls=a.girls();
cout<<"學生總數:"<<total<<"人。 ";
cout<<"其中,男生:"<<boys<<"名。";
cout<<"女生:"<<girls<<"名。 ";
system("pause");
}

voiderase(CStudent&a){
intselect;
unsignedid;
stringname;
student*p,*q;
cout<<"1、按學號刪除 2、按姓名刪除 0、返回 ";
cin>>select;
switch(select){
case1:cout<<"請輸入學號:";cin>>id;
if(p=a.findid(id)){
q=p->m_next;
p->m_next=q->m_next;
deleteq;
cout<<"成功刪除"<<id<<"的信息。 ";
}
break;
case2:cout<<"請輸入姓名:";name=readstring();
if(p=a.findname(name)){
q=p->m_next;
p->m_next=q->m_next;
deleteq;
cout<<"成功刪除"<<name<<"的信息。 ";
}
break;
case0:return;
default:cout<<"選擇錯誤。 ";
}
system("pause");
}

voidmodify(CStudent&a){
intselect;
cout<<"1、按學號修改 2、按姓名修改 0、返回 ";
cin>>select;
switch(select){
case1:if(a.modifyid())cout<<"修改成功。 ";break;
case2:if(a.modifyname())cout<<"修改成功。 ";break;
case0:return;
default:cout<<"選擇錯誤。 ";
}
system("pause");
}

intmain(){
CStudenta;
intan;
do{
an=menu();
switch(an){
case1:a.entering();break;
case2:a.Show();break;
case3:a.query();break;
case4:a.entering();break;
case5:statistics(a);break;
case6:erase(a);break;
case7:modify(a);break;
case0:break;
default:cout<<"選擇錯誤。 ";break;
}
}while(an);
return0;
}

閱讀全文

與學生綜合管理系統源碼相關的資料

熱點內容
linux伺服器怎麼連接外網地址 瀏覽:887
手機linux鏡像 瀏覽:659
u盤文件解壓時顯示文件損壞 瀏覽:659
美團php面試題 瀏覽:939
移動硬碟加密損傷硬碟嗎 瀏覽:141
dos關閉程序命令 瀏覽:374
微信下載的pdf文件保存在哪裡 瀏覽:500
qt加密文本 瀏覽:241
pdf如何轉換為圖片 瀏覽:888
大師兄影視下載解壓密碼 瀏覽:146
程序員做程序視頻 瀏覽:239
python和c語言的差別 瀏覽:414
電腦進入文件夾右鍵卡死 瀏覽:400
javasocket重連 瀏覽:925
我認為打籃球最解壓英語翻譯 瀏覽:577
php淘寶api調用實例 瀏覽:8
做單pdf下載 瀏覽:560
小游戲安卓轉蘋果區怎麼做 瀏覽:951
阿里雲飢荒專用伺服器ping高 瀏覽:596
php通過stmp發送郵件 瀏覽:790