diff --git a/2.cpp b/2.cpp new file mode 100644 index 0000000..bb2d476 --- /dev/null +++ b/2.cpp @@ -0,0 +1,514 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#define N 100 + +void menu(); +void ss(); +void tushuluru(); +void tushuchaxun(); +void zuozhemingchaxun(); +void tushuliulan(); +void shumingchaxun(); +void xinxixiugai(); +void tushuxinxixiugai(); +void tushuxinxishanchu(); +void huanyingxitong(); + +struct xinxi +{ + char name[100]; + char author[100]; + char publisher[100]; + int year,yue,ri; + int price,amount; + int kuchun; +} tushuxinxu[N] ; + +char mima[1000]; + +void goto_xy(int x, int y) //定位光标位置到指定坐标 +{ + HANDLE hOut; + hOut = GetStdHandle(STD_OUTPUT_HANDLE); + COORD pos = { x,y }; + SetConsoleCursorPosition(hOut, pos); +} + +void color(short x) //自定义函根据参数改变颜色 +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x); //只有一个参数,改变字体颜色 +} + +void tushuluru() +{ + int uu,j; + void ss(); + j=0; + printf("请输入你要插入的图书信息\n"); + printf("在录入图书年月日信息时:请这样输入日 月 年\n"); + printf("名称\t作者\t日-月-年\t价格\t数量\t库存\t出版社\n"); + FILE*fp; +out: + fp=fopen("a.txt","a+"); + scanf("%s%s%d%d%d%d%d%d%s",tushuxinxu[j].name,tushuxinxu[j].author,&tushuxinxu[j].year,&tushuxinxu[j].yue,&tushuxinxu[j].ri,&tushuxinxu[j].price,&tushuxinxu[j].amount,&tushuxinxu[j].kuchun,tushuxinxu[j].publisher); + fprintf(fp,"%s\t%s\t%d-%d-%d\t%d\t%d\t%d\t%s\n",tushuxinxu[j].name,tushuxinxu[j].author,tushuxinxu[j].year,tushuxinxu[j].yue,tushuxinxu[j].ri,tushuxinxu[j].price,tushuxinxu[j].amount,tushuxinxu[j].kuchun,tushuxinxu[j].publisher); + rewind(fp); + Sleep(1200); + printf("录入成功\n"); + fclose(fp); + printf("你是否还要录入信息\n"); + printf("如果是,请输入1,否则,输入2\n"); + scanf("%d",&uu); + if(uu==1) + { + goto out; + j++; + } + else + { + system("cls"); + ss(); + } +} +void huanyingxitong() +{ + system("cls"); + printf("谢谢你使用本系统,thanks\n"); + Sleep(1200); + system("cls"); + menu(); +} + +void ss()//图书管理系统界面 +{ + int x,y; + printf("****************图书管理系统界面***************\n"); + printf(" 1:图书信息录入\n"); + printf(" 2:图书信息浏览\n"); + printf(" 3:图书查询\n"); + printf(" 4:图书单价的修改与图书信息删除\n"); + printf(" 5:退出系统AND欢迎词\n"); + printf("**************************************************\n"); + printf("请输入你要选择的菜单\n"); + printf("\n"); + printf("你选择的是:"); + while(1) + { + scanf("%d",&x); + fflush(stdin); + if(x>5||x<1) + { + printf("输入错误,请重新输入:"); + continue; + } + break; + } //进入图书管理系统进行操作 + if(x==1) + { + system("cls"); + tushuluru(); + } + if(x==2) + { + printf("请稍等......\n"); + Sleep(500); + printf("恭喜你查询成功\n"); + Sleep(1200); + system("cls"); + tushuliulan(); + } + if(x==3) + { + printf("请稍等......\n"); + Sleep(500); + printf("恭喜你进入成功\n"); + Sleep(1200); + system("cls"); + tushuchaxun(); + } + if(x==4) + { + printf("请稍等......\n"); + Sleep(500); + printf("恭喜你进入成功\n"); + Sleep(1200); + system("cls"); + xinxixiugai(); + }if(x==5) + { + huanyingxitong(); + } +} +void xinxixiugai() +{ + int i; + printf("1:图书单价的修改\n"); + printf("2:图书信息的删除\n"); + printf("你想输入的数字是:"); + ww:scanf("%d",&i); + fflush(stdin); + if(i==1) + { + tushuxinxixiugai(); + system("cls"); + } + else if(i==2) + { + tushuxinxishanchu(); + system("cls"); + }if(i!=1||i!=2) + { + printf("你输入错误,请重新输入\n"); + goto ww; + } +} +void tushuxinxixiugai() +{ + int j,h,q,w,e,z,i; + xx:FILE*fp; + FILE*CC; + e=0; + z=0; + j=0; + fp=fopen("a.txt","r+"); + while(!feof(fp)) + { + fscanf(fp,"%s%s%d%d%d%d%d%d%s",tushuxinxu[j].name,tushuxinxu[j].author,&tushuxinxu[j].year,&tushuxinxu[j].yue,&tushuxinxu[j].ri,&tushuxinxu[j].price,&tushuxinxu[j].amount,&tushuxinxu[j].kuchun,tushuxinxu[j].publisher); + j++; + } + rewind(fp); + fclose(fp); + CC=fopen("a.txt","w+"); + printf("请问你想改正的单价是:"); + scanf("%d",&q); + for(h=0;h