c语言课程设计_图书资料管理系统
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#define N 5
struct library
{
int num,total,left,price;
char book_name[30];
char writer[30];
char sort_num[3];
char pub_company[30];
char pub_time[30];
}lib[N];
FILE *fp;
int all=0;
int menu(void);
void input(void);
void output(void);
void save(void);
void del(void);
void search(void);
void xiugai(void);
void tongji(void);
main()
{textbackground(7);
textcolor(128);
for(;;)
{
switch(menu())
{
case 1:input();break;
case 2:output();break;
case 3:save();break;
case 4:search();break;
case 5:xiugai();break;
case 6:del();break;
case 7:tongji();break;
case 0:exit(1);break;
}
}
}
int menu(void)
{
char m[3];
int n;
printf(" *********************WELCOME**********************\n\n\n\n\n");
printf("\t\t\t-----TU SHU ZI LIAO GUAN LI XI TONG----\n");
printf("_______________________________________________________________________________\n");
printf("\t\t1:input\n");
printf("_______________________________________________________________________________\n");
printf("\t\t2:output\n");
printf("_______________________________________________________________________________\n");
printf("\t\t3:save\n");
printf("_______________________________________________________________________________\n");
printf("\t\t4:search\n");
printf("_______________________________________________________________________________\n");
printf("\t\t5:xiugai\n");
printf("_______________________________________________________________________________\n");
printf("\t\t6:del\n");
printf("_______________________________________________________________________________\n");
printf("\t\t7:tongji\n");
printf("_______________________________________________________________________________\n");
printf("\t\t0:exit\n");
printf("_______________________________________________________________________________\n");
printf("\t\tplease choose a operation(0-7):\n");
scanf("%s",m);
n=atoi(m);
return(n);
}
void input(void)
{
int i;
char m[3];
for(i=all;i<N;i++)
{
all++;
printf("please input informations:\n");
printf("\t\tnum:\n");
scanf("%d",&lib[i].num);
printf("\t\ttotal:\n");
scanf("%d",&lib[i].total);
printf("\t\tleft:\n");
scanf("%d",&lib[i].left);
printf("\t\tbook_name:\n");
scanf("%s",lib[i].book_name);
printf("\t\twriter:\n");
scanf("%s",lib[i].writer);
printf("\t\tsort_num:\n");
scanf("%s",lib[i].sort_num);
printf("\t\tpub_company:\n");
scanf("%s",lib[i].pub_company);
printf("\t\tpub_time:\n");
scanf("%s",lib[i].pub_time);
printf("\t\tprice:\n");
scanf("%d",&lib[i].price);
a: printf("\t\tyes/no continue input?\n");
printf("\t\t1:yes\n");
printf("\t\t2:no\n");
scanf("%s",m);
if(atoi(m)==1)
continue;
else if(atoi(m)==2)
return;
else
{
printf("\t\tinput error!\n");
goto a;
}
}
}
void output(void)
{
int i;
for(i=0;i<all;i++)
{
printf("\tnum:%d\ttotal:%d\tleft:%d\n",lib[i].num,lib[i].total,lib[i].left);
printf("\tname:%s\twriter:%s\tsort_num:%s\n",lib[i].book_name,l
相关新闻>>
- 发表评论
-
- 最新评论 更多>>