大一C语言课程设计图书信息管理系统Word文件下载.docx

上传人:b****5 文档编号:17468319 上传时间:2022-12-01 格式:DOCX 页数:18 大小:96.27KB
下载 相关 举报
大一C语言课程设计图书信息管理系统Word文件下载.docx_第1页
第1页 / 共18页
大一C语言课程设计图书信息管理系统Word文件下载.docx_第2页
第2页 / 共18页
大一C语言课程设计图书信息管理系统Word文件下载.docx_第3页
第3页 / 共18页
大一C语言课程设计图书信息管理系统Word文件下载.docx_第4页
第4页 / 共18页
大一C语言课程设计图书信息管理系统Word文件下载.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

大一C语言课程设计图书信息管理系统Word文件下载.docx

《大一C语言课程设计图书信息管理系统Word文件下载.docx》由会员分享,可在线阅读,更多相关《大一C语言课程设计图书信息管理系统Word文件下载.docx(18页珍藏版)》请在冰豆网上搜索。

大一C语言课程设计图书信息管理系统Word文件下载.docx

intsort;

charbook_name[15];

charauthor_name[15];

intvert_number;

charpublish,unit[15];

charpublish_time[10];

intprice;

}B

(4).模块设计

根据功能需要:

源文件

函数名

功能

save()

保存

input()

输入

get()

获取

output()

输出

bookname

通过书名查找

authorname()

通过作者查找

modify()

修改

delet()

删除

(5)总体设计思想:

图书信息管理系

数据输入

N

数据浏览]数据查找[删除和修改

退出

Lj

(6)调试过程:

测试数据及结果,出现了哪些问题

截图略

(7)程序有待改进的地方及本次实习的收获和建议

(8)源程序清单(主要代码)

#include<

stdio.h>

stdlib.h>

string.h>

#defineLENsizeof(structbook)

intvert_number;

charpublish_unit[15];

intprice;

}B;

B*P,*p1,boo;

intnum=0,f=0;

intsave();

voidinput();

intget();

voidoutput();

voidbook_name();

voidauthor_name();

voidmodify();

voiddelet();

intmain()

intre=1,t,j=0;

intn,choice;

while(re==1){t=1;

printf("

主菜单\n\n"

);

1.

录入信息\n"

2.

查看信息\n"

3.

查询信息\n"

4.

删除与修改信息\n"

5.

退出\n"

system("

cls"

***************************

**\n"

n*****************************“‘

\n"

if(j==1)printf("

\n\t选择错误!

"

printf("

\n\t请选择1-5:

_\b\b"

scanf("

%d"

&

choice);

switch(choice)

case1:

\n\t1:

录入信息\n"

input();

\n\t1.返回主菜单;

\n\t2.退出\n\t\t请选择:

re);

break;

}

case2:

{printf("

\n\t2.查看信息\n"

output();

\n\t1.返回主菜单;

case3:

{while(t==1){

\n\t3.查询信息\n"

\n\t请选择查询方式:

\n\t1.按书名\n\t2.按作者名\n\t3.其余任意数字键返回主菜单_\b\b"

scanf("

n);

if(n==1)

book_name();

elseif(n==2)

author_name();

else

re=1;

gotolebel;

\n\t1.返回上一层;

\n\t2.返回主菜单;

\n\t3.退出

\n\t请选择:

t);

if(t==1)

if(t==2)

if(t==3)re=0;

}lebel:

break;

delet();

elseif(n==2)modify();

gotolebe;

}printf("

\n\t1.

退出\n\t\t请选择:

if(t==2)re=1;

lebe:

case5:

re=0;

default:

j=1;

}return0;

intsave()

FILE*fp;

inti,n=0,n1=0;

if((fp=fopen("

book.txt"

"

a+"

))==NULL)

return0;

fprintf(fp,"

%d\n"

num);

for(i=0;

i<

num;

i++)

%d%s%s%d%s%s%d"

P[i].sort,P[i].book_name,

P[i].author_name,P[i].vert_number,P[i].publish_unit,P[i].publish_time,P[i].price);

fclose(fp);

return1;

intget()

inti;

fp=fopen("

r"

if(fp==NULL)

else{fscanf(fp,"

num);

if(num>

0)

P=(B*)malloc(LEN*num);

fscanf(fp,"

%d%s%s%d%s%s%d"

P[i].sort,P[i].book_name,

P[i].author_name,&

P[i].vert_number,P[i].publish_unit,P[i].publish_time,&

P[i].price);

voidinput()

intresult;

\t\t要录入信息的书籍数量为:

__本\b\b"

P[i].sort=i+1;

\n\tNO.%d"

P[i].sort);

出版时间

\t请按序输入:

书名作者名分类号出版单位价格\n\t\t"

%s%s%d%s%s%d"

P[i].book_name,P[i].author_name,&

P[i].vert_number,P[i].publish_unit,

P[i].publish_time,&

P[i].price);

result=save();

if(result==0)

\n\t\tNO.\t%d\n"

\t\t书名作者名序列号出版单位出版时间格\n"

\t\t%s%s%d%s%s%d"

P[i].book_name,P[i].author_name,P[i].vert_number,P[i].publish_unit,

P[i].publish_time,P[i].price);

elseprintf("

\t文件打开错误!

voidbook_name()

inttag=0;

charch[15];

\t请输入书名:

%s"

ch);

if(get()==0)

\t无法查询!

return;

if(get()==1)

if(strcmp(P[i].book_name,ch)==0)

出版

\n\t\t排列号书名作者名序列号出版单位时间价格\n"

\t\t%d%s%s%d%s%s%d\n"

P[i].sort,P[i].book_name,

P[i].author_name,P[i].vert_number,P[i].publish_unit,P[i].publish_time,P[i].price);

tag=1;

if(tag==0)

\n\t没有相关信息!

voidauthor_name()

\t请输入作者名:

if(strcmp(P[i].author_name,ch)==0)

出版单位出

\n\t\t排列号书名作者名序列号版时间价格\n"

P[i].sort,P[i].book_name,

\t没有相关信息!

voidmodify()

intt,n,i,y=1;

intresult,z,x;

t=get();

if(t==0)

\n\t打开文件错误,无法修改!

return;

elseif(y==1)

\n\t您要修改信息的图书排列号为(1-%d):

if(n>

=1&

&

n<

=num)

if(P[i].sort==n){

\n\t您即将修改以下信息:

价格\n"

\t\t%d%s%s%d%s%s%d"

P[i].author_name,P[i].vert_number,P[i].publish_unit,

\n\n\t确认请按1;

返回请按2;

返回上一层请按3_\b\b"

x);

if(x==1)

//p1=&

boo;

\t您要将信息修改为:

\t\t书名:

P[i].book_name);

\t\t作者名:

P[i].author_name);

\t\t序列号:

P[i].vert_number);

\t\t出版单位:

P[i].publish_unit);

\t\t出版时间:

P[i].publish_time);

\t\t价格:

strcpy(P[i].book_name,P[i].book_name);

strcpy(P[i].author_name,P[i+1].author_name);

P[i].vert_number=P[i+1].vert_number;

strcpy(P[i].publish_unit,P[i+1].publish_unit);

strcpy(P[i].publish_time,P[i+1].publish_time);

P[i].price=P[i+1].price;

y=0;

z=1;

if(x==2)

y=1;

z=0;

f=1;

}else

\t输入错误,请重新输入:

y=1;

while(z==1)

\n\t修改信息失败!

z=0;

if(result==1)

\n\t成功修改信息!

voiddelet()

intt,n,i,j,y=1;

intresult,z=0,x;

打开文件错误,无法删除!

您要删除信息的图书排列号为(1-%d):

\n\treturn;

while(y==1)

\n\t

if(P[i].sort==n)

\n\t您即将删除以下信息:

\t\t排列号书名作者名序列号出版单位出版

时间价格\n"

for(j=i;

j<

num-1;

j++)

strcpy(P[j].book_name,P[j+1].book_name);

strcpy(P[j].author_name,P[j+1].author_name);

P[j].vert_number=P[j+1].vert_number;

strcpy(P[j].publish_unit,P[j+1].publish_unit);

strcpy(P[j].publish_time,P[j+1].publish_time);

P[j].price=P[j+1].price;

num=num-1;

\n\t删除信息失败!

\n\t成功删除信息!

}return;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1