书本源码
Ⅰ c语言程序设计图书馆源代码
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
typedef int BOOL;
typedef struct bookinfo
{
char number[15];/*产品编号*/
char name[30];/*产品名称*/
float price;/*单价*/
char auther[20];/*作者*/
BOOL isExit;/*存在状态*/
char lendername[20];/*借书人姓名*/
char lendersex[2];/*借书人性别*/
char lendernum[15];/*借书人学号*/
}BOOKINFO;
void menu()
{
printf("\n\n\n\n\n\n\n");
printf("\t\t\t图书管理系统\n");
printf("\t\t\t1:新进图书基本信息的输入\n");
printf("\t\t\t2:显示全部记录\n");
printf("\t\t\t3:根据图书名称查询图书基本信息\n");
printf("\t\t\t4:根据图书名称对撤销的图书信息进行删除\n");
printf("\t\t\t5:按照图书名称从小大到排序\n");
printf("\t\t\t6:统计某价格以上的图书数量\n");
printf("\t\t\t7:列出所有未借出去的图书信息\n");
printf("\t\t\t8:退出\n");
}
void choice_1_input_new()/*输入新进的图书信息*/
{
char choice;
FILE *p;
BOOKINFO newbook;
system("cls");
while(1)
{
printf("输入图书编号:");
gets(newbook.number);
printf("输入图书名称:");
gets(newbook.name);
printf("输入图书单价:");
scanf("%f",&newbook.price);
while(getchar()!='\n');
printf("输入图书的作者:");
gets(newbook.auther);
printf("输入借书人姓名:");
gets(newbook.lendername);
printf("输入借书人性别:");
gets(newbook.lendersex);
printf("输入借书人学号:");
gets(newbook.lendernum);
printf("是否保存该条书目?(Y/N)\n");
if(choice=='Y'||choice=='y')
{
newbook.isExit=1;/*将图书状态设置成1,表示没有借出*/
p=fopen("c:\\bookinfo.data","ab");
fwrite(&newbook,sizeof(BOOKINFO),1,p);
fclose(p);
printf("\n该条书目已添加到c:\\bookinfo.data文件中!\n");
}
else
{
printf("\n本条书目未保存!\n");
}
printf("\n是否继续添加书目?(Y/N)\n");
while(choice!='Y'&&choice!='y'&&choice!='N'&&choice!='n')
if(choice=='Y'||choice=='y')
continue;
else
break;
}
}
void choice_2_display_all()/*显示全部图书信息*/
{
FILE *p;
int n;
BOOKINFO bookinfo[100];
int booknumber=0;
system("cls");
p=fopen("c:\\bookinfo.data","rb");
while(!feof(p))
{
fread(&bookinfo[booknumber],sizeof(BOOKINFO),1,p);
booknumber++;
}
/*booknumber--;使用feof()函数会多读一行,因此需要booknumber自减一次,使书目的数量正确*/
fclose(p);
booknumber--;
if(booknumber==0)
{
printf("没有任何图书信息!\n\n");
}
else
{
n=0;
printf(" 图书信息如下\n");
printf(" 图书信息 | 借书人信息 \n");
printf("编号 名称 单价 作者 图书状态 | 姓名 性别 学号\n");
while(n<booknumber)
{
printf("%-6s%-12s%-8.1f%-8s%-9d| %-12s%-8s%-8s\n",
bookinfo[n].number,bookinfo[n].name,bookinfo[n].price,
bookinfo[n].auther,bookinfo[n].isExit,bookinfo[n].lendername,
bookinfo[n].lendersex,bookinfo[n].lendernum);
n++;
}
}
printf("\n\n按任意键回到主菜单!\n");
}
void choice_3_search_according_name()/*根据图书名称显示图书的信息*/
{
char search[20]="";/*search用来存放要查询的书名*/
int n;
FILE *p;
char choice;
BOOKINFO bookinfo[100];
int booknumber=0;
system("cls");
p=fopen("c:\\bookinfo.data","rb");
while(!feof(p))
{
fread(&bookinfo[booknumber],sizeof(BOOKINFO),1,p);
booknumber++;
}
booknumber--;/*使用feof()函数会多读一行,因此需要booknumber自减一次,使书目的数量正确*/
fclose(p);
while(1)
{
printf("输入要查询的书本名称:");
gets(search);
if(booknumber==0)
{
printf("书库中没有任何信息!\n\n");
printf("按任意键回到主菜单!\n\n");
getch();
break;
}/*if结束*/
else
{
for(n=0;n<booknumber;n++)
if(strcmp(bookinfo[n].name,search)==0)
{
printf("该书的详细信息如下:\n");
printf(" 图书信息 | 借书人信息 \n");
printf("编号 名称 单价 作者 图书状态 | 姓名 性别 学号\n");
printf("%-6s%-12s%-8.1f%-8s%-9d| %-12s%-8s%-8s\n",
bookinfo[n].number,bookinfo[n].name,bookinfo[n].price,
bookinfo[n].auther,bookinfo[n].isExit,bookinfo[n].lendername,
bookinfo[n].lendersex,bookinfo[n].lendernum);
break;
}
if(n>=booknumber)
printf("没有查找该书的任何信息!\n");
printf("\n\n是否继续查询?(Y/N)\n");
choice=getch();
while(choice!='Y'&&choice!='y'&&choice!='N'&&choice!='n')
choice=getch();
if(choice=='Y'||choice=='y')
continue;
else
break;
}/*else结束*/
}/*while(1)结束*/
}
void choice_4_delete_according_name()/*根据图书名称对图书信息进行删除*/
{
char search[20]="";/*search用来存放要删除的书名*/
int n,i;
FILE *p;
char choice;
BOOKINFO bookinfo[100];
int booknumber;
system("cls");
while(1)
{
printf("输入要删除的书本名称:");
gets(search);
p=fopen("c:\\bookinfo.data","rb");
booknumber=0;
while(!feof(p))
{
fread(&bookinfo[booknumber],sizeof(BOOKINFO),1,p);
booknumber++;
}
booknumber--;/*使用feof()函数会多读一行,因此需要booknumber自减一次,使书目的数量正确*/
fclose(p);
if(booknumber==0)
{
printf("书库中没有任何信息!\n\n");
printf("按任意键回到主菜单!\n\n");
getch();
break;
}/*if结束*/
else
{
for(n=0;n<booknumber;n++)
if(strcmp(bookinfo[n].name,search)==0)
{
break;
}
if(n>=booknumber)
printf("没有查找该书的任何信息!\n");
else
{
printf("是否确认需要删除该条书目?(Y/N)");
choice=getch();
while(choice!='Y'&&choice!='y'&&choice!='N'&&choice!='n')
choice=getch();
if(choice=='Y'||choice=='y')
{
for(i=n;i<booknumber-1;i++)
bookinfo[i]=bookinfo[i+1];
booknumber--;
p=fopen("c:\\bookinfo.data","wb");
for(n=0;n<booknumber;n++)
fwrite(&bookinfo[n],sizeof(BOOKINFO),1,p);
fclose(p);
printf("删除成功!\n");
}
else
printf("\n\n该条书目没有被删除!");
}
printf("\n\n是否继续进行删除操作?(Y/N)\n");
choice=getch();
while(choice!='Y'&&choice!='y'&&choice!='N'&&choice!='n')
choice=getch();
if(choice=='Y'||choice=='y')
continue;
else
break;
}/*else结束*/
}/*while(1)结束*/
}
void choice_5_sort_according_name()/*根据图书名称排序*/
{
FILE *p;
int m,n;
BOOKINFO temp;
BOOKINFO bookinfo[100];
int booknumber;
p=fopen("c:\\bookinfo.data","rb");
booknumber=0;
system("cls");
while(!feof(p))
{
fread(&bookinfo[booknumber],sizeof(BOOKINFO),1,p);
booknumber++;
}
booknumber--;/*使用feof()函数会多读一行,因此需要booknumber自减一次,使书目的数量正确*/
fclose(p);
if(booknumber==0)
{
printf("没有任何图书信息!\n\n");
}
else
{
for(m=0;m<booknumber-1;m++)
for(n=m+1;n<booknumber;n++)
if(strcmp(bookinfo[m].name,bookinfo[n].name)>0)
{
temp=bookinfo[m];
bookinfo[m]=bookinfo[n];
bookinfo[n]=temp;
}
p=fopen("c:\\bookinfo.data","wb");
for(m=0;m<booknumber;m++)
fwrite(&bookinfo[m],sizeof(BOOKINFO),1,p);
fclose(p);
printf("\n\n完成排序!\n\n");
}
printf("按任意键回到主菜单!\n");
getch();
}
void choice_6_display_high_price()/*根据价格列出图书信息*/
{
float price;
FILE *p;
int n;
int count=0;
BOOKINFO bookinfo[100];
int booknumber;
system("cls");
printf("请输入价格:");
scanf("%f",&price);
p=fopen("c:\\bookinfo.data","rb");
booknumber=0;
while(!feof(p))
{
fread(&bookinfo[booknumber],sizeof(BOOKINFO),1,p);
booknumber++;
}
booknumber--;/*使用feof()函数会多读一行,因此需要booknumber自减一次,使书目的数量正确*/
fclose(p);
if(booknumber==0)
{
printf("没有任何图书信息!\n\n");
}
else
{
for(n=0;n<booknumber;n++)
{
if(bookinfo[n].price>=price)
count++;
}
if(count==0)
printf("书库中没有比%.1f$价格高的图书!",price);
else
{
printf(" 价格高于%.1f$的图书信息如下\n",price);
printf(" 图书信息 | 借书人信息 \n");
printf("编号 名称 单价 作者 图书状态 | 姓名 性别 学号\n");
for(n=0;n<booknumber;n++)
{
if(bookinfo[n].price>=price)
printf("%-6s%-12s%-8.1f%-8s%-9d| %-12s%-8s%-8s\n",
bookinfo[n].number,bookinfo[n].name,bookinfo[n].price,
bookinfo[n].auther,bookinfo[n].isExit,bookinfo[n].lendername,
bookinfo[n].lendersex,bookinfo[n].lendernum);
}
}
}
printf("\n\n按任意键回到主菜单!\n");
getch();
}
void choice_7_display_according_exitflag()/*根据存在状态列出图书信息*/
{
FILE *p;
int n;
int count=0;
BOOKINFO bookinfo[100];
int booknumber;
system("cls");
booknumber=0;
p=fopen("c:\\bookinfo.data","rb");
while(!feof(p))
{
fread(&bookinfo[booknumber],sizeof(BOOKINFO),1,p);
booknumber++;
}
booknumber--;
fclose(p);
if(booknumber==0)
{
printf("书库中没有任何书目存在!\n");
}
else
{
for(n=0;n<booknumber;n++)
if(bookinfo[n].isExit==1)
count++;
if(count==0)
printf("书库中的书籍全部借出!\n");
else
{
printf("书库中未被借出的图书信息如下:\n\n");
printf(" 图书信息 | 借书人信息 \n");
printf("编号 名称 单价 作者 图书状态 | 姓名 性别 学号\n");
for(n=0;n<booknumber;n++)
if(bookinfo[n].isExit==1)
{
printf("%-6s%-12s%-8.1f%-8s%-9d| %-12s%-8s%-8s\n",
bookinfo[n].number,bookinfo[n].name,bookinfo[n].price,
bookinfo[n].auther,bookinfo[n].isExit,bookinfo[n].lendername,
bookinfo[n].lendersex,bookinfo[n].lendernum);
}
}
}
printf("\n按任意键返回主菜单!\n");
getch();
}
void main()
{
char choice;
clock_t tm;
FILE *p;
if((p=fopen("c:\\bookinfo.data","rb"))==NULL)
{
p=fopen("c:\\bookinfo.data","wb");
fclose(p);
}
while(1)
{
system("cls");
menu();
choice=getch();
switch(choice)
{
case '1':choice_1_input_new();break;/*输入新进的图书信息*/
case '2':choice_2_display_all();break;/*显示全部图书信息*/
case '3':choice_3_search_according_name();break;/*根据图书名称显示图书的信息*/
case '4':choice_4_delete_according_name();break;/*根据图书名称对图书信息进行删除*/
case '5':choice_5_sort_according_name();break;/*根据图书名称排序*/
case '6':choice_6_display_high_price();break;/*根据价格列出图书信息*/
case '7':choice_7_display_according_exitflag();break;/*根据存在状态列出图书信息*/
case '8':printf("\n\n\t\t\t谢谢使用,再见!\n\t\t\t按任意键退出!\n");getch();return;
default:
printf("\n\n\t\t\t请输入菜单中的数字!(1~8)");
tm=clock();
while(clock()<tm+1800);
break;
}
}
}
Ⅱ 《python编程初学者指南》书本中的涉及的源码哪里可以下载
感谢楼上伙伴的无私分享~
虽然已经是5年前的提问了,不过我还是想在这里补充回答一下,虽然书中指定的网址已经发生了变化,但依然有效,输入原网址后会跳转到新的网址。因为网站中包含很多书籍的信息和配套资源,所以需要我们根据书籍的作者或书名或ISBN手动搜索到这本书,
上面页面对应的网址是:
网页链接
不过资源下载起来很慢……建议直接使用楼上的分享~
Ⅲ 下载了一个图书管理系统源码其中数据库book.data文件如何打开呢
这应该是分离后的文件,先把data放到你知道的位置,哪个盘都可以,打开SQL2000然后右击“数据库”选所有任务里的附加数据库,找到你放的data文件就OK了
Ⅳ thinking in java(java编程思想) 第三版的书本配套源码那里有下载啊
http://www.codedn.com/view/240.html
http://so.xunlei.com/search?search=java%E6%BA%90%E4%BB%A3%E7%A0%81&restype=-1&sortby=3&suffix=&page=1&id=1
看看是不是你要的那种
Ⅳ 急求用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();
}
Ⅵ android从入门到精通书本源代码谁有
我有,自己去网盘里下吧
Ⅶ thinking in java(java编程思想) 第三版的书本配套源码和练习的答案
你都没有留下联系方式,怎么发给你了?