c语言程序设计题图书管理系统
功能描述:(1)新进图书基本信息的输入。(2)图书基本信息的查询。(3)对撤消图书信息的删除。(4)为借书人办理注册。(5)办理借书手续(非注册会员不能借书)。(6)办理...
功能描述:
(1)新进图书基本信息的输入。
(2) 图书基本信息的查询。
(3) 对撤消图书信息的删除。
(4)为借书人办理注册。
(5)办理借书手续(非注册会员不能借书)。
(6)办理还书手续
信息描述:有关该系统基本信息的描述,如:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等 展开
(1)新进图书基本信息的输入。
(2) 图书基本信息的查询。
(3) 对撤消图书信息的删除。
(4)为借书人办理注册。
(5)办理借书手续(非注册会员不能借书)。
(6)办理还书手续
信息描述:有关该系统基本信息的描述,如:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等 展开
展开全部
/* Note:Your choice is C IDE */
#include "stdio.h"
#include<graphics.h>
#include "conio.h"
#include<stdlib.h>
#include<string.h>
void main()
{void adm1(),adm2(),build(),huan(),borrow(),dele();
adm1();
}
void adm1()
{ FILE *fp,*p ;
char adp[20],password[20];
int i,n=0;
textbackground(2);
clrscr();
gotoxy(25,12);
fp=fopen("pass","r");
if(fp==NULL) { printf("no exit ");getch();exit(0);}
printf("input password:");
for(;;)
{
window(42,12,53,12);
textbackground(0);
clrscr();
gets(adp);
for(i=0;adp[i]!='\0';i++);
fgets(password,i+1,fp);
gotoxy(55,12);
if(strcmp(password,adp)==0) { window(55,12,70,12);clrscr();cprintf("YES");getch();adm2();getch();exit(0);}
else{ n++;
window(55,12,60,12);clrscr();gotoxy(55,12);cprintf("error");
for(i=0;i<30;i++) delay(8000);
if(n==2) { window(55,12,70,12);clrscr();gotoxy(55,12);cprintf("once again");for(i=0;i<=30;i++) delay(8000);}
if(n==3) { window(55,12,70,12);clrscr();gotoxy(55,12);cprintf("3 second out");for(i=0;i<=30;i++) { delay(8000);}
exit(0);
}
}
fclose(fp);clrscr();
}
}
void adm2()
{ char a;
window(1,1,80,25);
clrscr();
for(;;)
{ clrscr();
gotoxy(30,8);printf("built a new user (B)");
gotoxy(30,10);printf("return book (R)");
gotoxy(30,12);printf("borrow books (J)");
gotoxy(30,14);printf("delete user (D)");
a=getch();
if(a=='b') build();
if(a=='r') huan();
if(a=='j') borrow();
if(a=='d') dele();
else continue;
}
}
void build()
{ FILE *f,*p;
char id[20],name[20],sex[2],age[3],grad[50];
window(1,1,80,25);
clrscr();
printf("ID number:");
scanf("%s",id);
printf("name:");
scanf("%s",name);
printf("sex:");
scanf("%s",sex);
printf("grad:");
scanf("%s",grad);
p=fopen(id,"w+");
if(p==NULL) { printf("can't build that user");getch();adm2();}
fprintf(p,"%s ",name);
fprintf(p,"%s ",id);
fprintf(p,"%s ",sex);
fprintf(p,"%s ",grad);
printf("bulid success");
getch();
fclose(p);
}
void huan()
{
FILE *fp,*p,*f;
char id[20],a[5][50],name[20],c;
int i=0,m,k; clrscr();
printf("input ID number:");
scanf("%s",id);
p=fopen(id,"r");
if(p==NULL) { printf("error");getch();fclose(p);exit(0);}
fscanf(p,"%s",name);
fclose(p);
fp=fopen(name,"r");
do{ fscanf(fp,"%s",a[i++]); }while(!feof(fp));
for(k=0;k<i-1;k++) printf("\nbook %d: %s",k+1,a[k]);
fclose(fp);
f=fopen(name,"w+");
for(;;)
{
printf("\n\npress the book number that you want to return. \n\nPress 6 if you want to return all. \n\npress 7 to cancle.\n");
scanf("%d",&m);
if(m==7) { for(k=0;k<i-1;k++)
{
fprintf(f,"%s\n",a[k]);
}
fclose(f);
adm2();
}
if(m==6) remove(name);
if(m<6)
for(k=0;k<i-1;k++)
{ if(k!=m-1)
fprintf(f,"%s\n",a[k]);
}
printf("book %d has returned.",m);
printf("\ncontinue? (Y/N)");
c=getch();
if(c=='y') continue;
if(c=='n') { fclose(f);adm2(); }
}
}
void borrow()
{ FILE *f,*m,*p;
char id[20],book[5][50],name[20],c;
int i=0,n=0,k;
window(1,1,80,25);clrscr();
printf("please input the user's ID:");
scanf("%s",id);
m=fopen(id,"r");
if(m==NULL) { printf("user no exit"); getch();fclose(m);adm2();}
fscanf(m,"%s",name);
fclose(m);
p=fopen(name,"r");
if(p==NULL);
else
{ while(!feof(p))
{
fscanf(p,"%s",book[i]);
i++;
}
i--;
for(k=0;k<i;k++) printf("\nbook %d :%s",k+1,book[k]);
}
fclose(p);
f=fopen(name,"w");
printf("\nhow many book do you want to borrow?:");
do{printf("\ninput:");scanf("%d",&n); }while(i+n>=6);
for(k=i;k<i+n;k++)
{ printf("\nbook %d :",k+1);
scanf("%s",book[k]);
}
for(k=0;k<i+n;k++) fprintf(f,"%s\n",book[k]);
fputc('\0',f);
printf("success");
fclose(f);
}
void dele()
{ FILE *fp,*f;
char id[20],a[4][20],c,b[5][50];
int i=0,j=0,k;
window(1,1,80,25);clrscr();
printf("Input ID number:");
scanf("%s",id);
fp=fopen(id,"r");
if(fp==NULL) { printf("\nuser isn't exit");getch(); fclose(fp);adm2();}
else while(!feof(fp))
{ fscanf(fp,"%s",a[i++]);}
printf("\nname: %s",a[0]);
printf("\nID: %s",a[1]);
printf("\nsex: %s",a[2]);
printf("\ngrad: %s",a[3]);
f=fopen(a[0],"r");
if(f==NULL);
else {
while(!feof(f))
{ fscanf(f,"%s",b[j++]);}
for(k=0;k<j-1;k++) printf("\nbook %d: %s",k+1,b[k]);
}
printf("\nDo you want to delete? (Y/N): ");
c=getch();
fclose(fp);
fclose(f);
if(c=='y') { remove(id);remove(a[0]);printf("\nsuccess");getch();adm2();}
if(c=='n') adm2();
}
先在当前文件夹下新建一个pass.txt文件输入密码,再把.txt去掉运行的程序就可以了。
这是我以前写的一个图书管理系统,可能和你的要求不符,暴怒过参考下也行
呵呵,希望有帮助
#include "stdio.h"
#include<graphics.h>
#include "conio.h"
#include<stdlib.h>
#include<string.h>
void main()
{void adm1(),adm2(),build(),huan(),borrow(),dele();
adm1();
}
void adm1()
{ FILE *fp,*p ;
char adp[20],password[20];
int i,n=0;
textbackground(2);
clrscr();
gotoxy(25,12);
fp=fopen("pass","r");
if(fp==NULL) { printf("no exit ");getch();exit(0);}
printf("input password:");
for(;;)
{
window(42,12,53,12);
textbackground(0);
clrscr();
gets(adp);
for(i=0;adp[i]!='\0';i++);
fgets(password,i+1,fp);
gotoxy(55,12);
if(strcmp(password,adp)==0) { window(55,12,70,12);clrscr();cprintf("YES");getch();adm2();getch();exit(0);}
else{ n++;
window(55,12,60,12);clrscr();gotoxy(55,12);cprintf("error");
for(i=0;i<30;i++) delay(8000);
if(n==2) { window(55,12,70,12);clrscr();gotoxy(55,12);cprintf("once again");for(i=0;i<=30;i++) delay(8000);}
if(n==3) { window(55,12,70,12);clrscr();gotoxy(55,12);cprintf("3 second out");for(i=0;i<=30;i++) { delay(8000);}
exit(0);
}
}
fclose(fp);clrscr();
}
}
void adm2()
{ char a;
window(1,1,80,25);
clrscr();
for(;;)
{ clrscr();
gotoxy(30,8);printf("built a new user (B)");
gotoxy(30,10);printf("return book (R)");
gotoxy(30,12);printf("borrow books (J)");
gotoxy(30,14);printf("delete user (D)");
a=getch();
if(a=='b') build();
if(a=='r') huan();
if(a=='j') borrow();
if(a=='d') dele();
else continue;
}
}
void build()
{ FILE *f,*p;
char id[20],name[20],sex[2],age[3],grad[50];
window(1,1,80,25);
clrscr();
printf("ID number:");
scanf("%s",id);
printf("name:");
scanf("%s",name);
printf("sex:");
scanf("%s",sex);
printf("grad:");
scanf("%s",grad);
p=fopen(id,"w+");
if(p==NULL) { printf("can't build that user");getch();adm2();}
fprintf(p,"%s ",name);
fprintf(p,"%s ",id);
fprintf(p,"%s ",sex);
fprintf(p,"%s ",grad);
printf("bulid success");
getch();
fclose(p);
}
void huan()
{
FILE *fp,*p,*f;
char id[20],a[5][50],name[20],c;
int i=0,m,k; clrscr();
printf("input ID number:");
scanf("%s",id);
p=fopen(id,"r");
if(p==NULL) { printf("error");getch();fclose(p);exit(0);}
fscanf(p,"%s",name);
fclose(p);
fp=fopen(name,"r");
do{ fscanf(fp,"%s",a[i++]); }while(!feof(fp));
for(k=0;k<i-1;k++) printf("\nbook %d: %s",k+1,a[k]);
fclose(fp);
f=fopen(name,"w+");
for(;;)
{
printf("\n\npress the book number that you want to return. \n\nPress 6 if you want to return all. \n\npress 7 to cancle.\n");
scanf("%d",&m);
if(m==7) { for(k=0;k<i-1;k++)
{
fprintf(f,"%s\n",a[k]);
}
fclose(f);
adm2();
}
if(m==6) remove(name);
if(m<6)
for(k=0;k<i-1;k++)
{ if(k!=m-1)
fprintf(f,"%s\n",a[k]);
}
printf("book %d has returned.",m);
printf("\ncontinue? (Y/N)");
c=getch();
if(c=='y') continue;
if(c=='n') { fclose(f);adm2(); }
}
}
void borrow()
{ FILE *f,*m,*p;
char id[20],book[5][50],name[20],c;
int i=0,n=0,k;
window(1,1,80,25);clrscr();
printf("please input the user's ID:");
scanf("%s",id);
m=fopen(id,"r");
if(m==NULL) { printf("user no exit"); getch();fclose(m);adm2();}
fscanf(m,"%s",name);
fclose(m);
p=fopen(name,"r");
if(p==NULL);
else
{ while(!feof(p))
{
fscanf(p,"%s",book[i]);
i++;
}
i--;
for(k=0;k<i;k++) printf("\nbook %d :%s",k+1,book[k]);
}
fclose(p);
f=fopen(name,"w");
printf("\nhow many book do you want to borrow?:");
do{printf("\ninput:");scanf("%d",&n); }while(i+n>=6);
for(k=i;k<i+n;k++)
{ printf("\nbook %d :",k+1);
scanf("%s",book[k]);
}
for(k=0;k<i+n;k++) fprintf(f,"%s\n",book[k]);
fputc('\0',f);
printf("success");
fclose(f);
}
void dele()
{ FILE *fp,*f;
char id[20],a[4][20],c,b[5][50];
int i=0,j=0,k;
window(1,1,80,25);clrscr();
printf("Input ID number:");
scanf("%s",id);
fp=fopen(id,"r");
if(fp==NULL) { printf("\nuser isn't exit");getch(); fclose(fp);adm2();}
else while(!feof(fp))
{ fscanf(fp,"%s",a[i++]);}
printf("\nname: %s",a[0]);
printf("\nID: %s",a[1]);
printf("\nsex: %s",a[2]);
printf("\ngrad: %s",a[3]);
f=fopen(a[0],"r");
if(f==NULL);
else {
while(!feof(f))
{ fscanf(f,"%s",b[j++]);}
for(k=0;k<j-1;k++) printf("\nbook %d: %s",k+1,b[k]);
}
printf("\nDo you want to delete? (Y/N): ");
c=getch();
fclose(fp);
fclose(f);
if(c=='y') { remove(id);remove(a[0]);printf("\nsuccess");getch();adm2();}
if(c=='n') adm2();
}
先在当前文件夹下新建一个pass.txt文件输入密码,再把.txt去掉运行的程序就可以了。
这是我以前写的一个图书管理系统,可能和你的要求不符,暴怒过参考下也行
呵呵,希望有帮助
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询