
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NAME_MAX 100//书的名字的最长字数
#define WRITER_MAX 100//作者名字的最长
#define PUB_MAX 100//出版单位最长名字
#define TIME 100//出版时间
typedef struct books
{
intloading
char name[NAME_MAX]
char writer[WRITER_MAX]
intidentify
char pub[PUB_MAX]
char time[TIME]
intprice
struct books * next
}book
//头结点不存储信息
void Init(book * head)
{
head->next=NULL
}
//打印一些欢迎词之类的。。。。。
void welcome()
{
printf("******欢迎使用@@@@图书馆,哈哈*********\n")
printf("\n\n")
printf("1:图书信息录入功能\n")
printf("2:图书信息浏览功能,显示该书的所有信息\n")
printf("3:图书信息查询功能:按书名查询与按作者名查询\n")
printf("4:图书信息的修改和删除,可对相应数据进行修改和删除\n")
}
//显示一本书的信息
void print_the_book(book * p1)
{
printf("loading number:%d \n",p1->loading)
printf("name: ")
puts(p1->name)
printf(" \n")
printf("writer: ")
puts(p1->writer)
printf(" \n")
printf("identify:%d ***\n",p1->identify)
printf(" \n")
printf("pub: ")
puts(p1->pub)
printf(" \n")
printf("time: ")
puts(p1->time)
printf(" \n")
printf("price:%d ***\n",p1->price)
}
int chongfu(book * head,book * p)
{
book * p1=head->next
int a=0
while(p1!=NULL)
{
if(strcmp(p1->name,p->name)==0)
{
if(strcmp(p1->writer,p->writer)==0)
{
a=1
break
}
}
else
p1=p1->next
}
return a
}
//录入一些信息。。。。
void luru(book * head)
{
book * p1=head
book * p2
//寻找NULL前的那个点
while(p1->next!=NULL)
{
p1=p1->next
}
int a
do
{
p2=(book *)malloc(sizeof(book))
printf("输入书本信息\n")
printf("登录号\n")
fflush(stdin)
scanf("%d",&p2->loading)
printf("书名\n")
fflush(stdin)
gets(p2->name)
fflush(stdin)
printf("作者\n")
gets(p2->writer)
fflush(stdin)
printf("分类号\n")
scanf("%d",&p2->identify)
fflush(stdin)
printf("出版社\n")
gets(p2->pub)
fflush(stdin)
printf("出版时间\n")
gets(p2->time)
fflush(stdin)
printf("价格\n")
scanf("%d",&p2->price)
p2->next=NULL
fflush(stdin)
//加入链表
if(chongfu(head,p2))
printf("录入信息重复\n")
else
{
p1->next=p2
p1=p2
}
printf("还想继续录入信息吗?\n(1:继续 0:停止)\n")
scanf("%d",&a)
}while(a==1)
}
void liulan(book * head)
{
book * p1=head->next
int i=1
while(p1!=NULL)
{
printf("*********第%d本书***********\n",i++)
print_the_book(p1)
p1=p1->next
}
}
//查询。。。。
void chaxun(book * head)
{
printf("按书名查询还是按作者名查询?\n(1:按书名查询 0:按作者名查询)\n")
book * p=head->next
int a
scanf("%d",&a)
int num=0
char cha[NAME_MAX]
switch(a)
{
case 1:
printf("输入书名:\n")
gets(cha)
while(p!=NULL)
{
if(strcmp(p->name,cha)==0)
{
num++
print_the_book(p)
}
p=p->next
}
break
case 2:
printf("输入作者名:\n")
gets(cha)
while(p!=NULL)
{
if(strcmp(p->writer,cha)==0)
{
num++
print_the_book(p)
}
p=p->next
}
}
if(num==0)
printf("无符合书本\n")
}
//修改信息
void xiugai(book * head)
{
printf("输入需要修改书本的名称和作者:\n")
char name_book[NAME_MAX]
char writer_book[WRITER_MAX]
printf("书本名称:")
gets(name_book)
gets(writer_book)
book * p1=head->next
int a=0
while(p1!=NULL)
{
if(strcmp(p1->name,name_book)==0)
{
if(strcmp(p1->writer,writer_book)==0)
{
a=1
break
}
}
}
if(a==0)
printf("没有这本书。。。\n")
else
{
print_the_book(p1)
printf("输入新信息\n")
scanf("%d",&p1->loading)
gets(p1->name)
gets(p1->writer)
scanf("%d",&p1->identify)
gets(p1->pub)
gets(p1->time)
scanf("%d",&p1->price)
}
}
void main()
{
book * head
head=(book *)malloc(sizeof(book))
Init(head)
int contin=1
while(contin)
{
welcome()
printf("想进行哪项 *** 作?\n")
int a
scanf("%d",&a)
switch(a)
{
case 1:
luru(head)
break
case 2:
liulan(head)
break
case 3:
chaxun(head)
break
case 4:
xiugai(head)
}
printf("继续使用图书馆还是退出?\n(1:continue 0:exit)\n")
scanf("%d",&contin)
}
}
相信很多人有这样的需求吧 推荐使用 Qt Creator 2.1 以上版本,因为自带了 Class View ,不需要第三方的插件就可以看Symbol了。新建项目里,选择 Other Project 然后是 Import Existing Project,建立项目后添加文件,最后需要的是自己写一个 Makefile, 而且默认的 Build 目标是 all,注意 GNU make 的文件格式,命令行开头需要一个完整的 TAB 针对最简单的单文件,比如 main.cpp ,makefile 可以这样写 all: g++ -o main main.cpp 然后就可以了。
如果你自己添加的第三方库也可以提供自动补全功能,但是需要能搜索到这个库目录,我用的是 Mingw ,直接把第三方库放到 Mingw 对应的 include 和 lib 目录了,引用头文件之后自动补全很好很强大。应该也有环境变量来设置的,不过暂时不大清楚如何 *** 作。 工具->选项->项目和解决方案 之后窗口右上方 “显示以下文件的目录” 默认是可执行文件
把它修改成“库文件” 就可以添加了。
1.添加库文件静态库linux:LIBS += your_lib_path/your_lib动态库
linux:LIBS += -L your_lib_path -lyour_lib//经过测试了
win32:LIBS += your_lib_path/your_lib例如:
LIBS += -L lib/pcsc/ -lpcsclite
LIBS += lib/pcsc/libpcsclite.a
2.添加头文件
INCLUDEPATH += your_include_path例如:
INCLUDEPATH += . /usr/local/include(点号后面有空格)
3.添加要编译的源文件和头文件
SOURCES:所有源文件列表
HEADERS:所有头文件列表
FORMS:所有.ui文件列表前期工作:
1.检查gcc,g++,qmake是否用错。
2.在Makefile中检查是否少了头文件
3.检查是否与<错用了
4.需要另外加库的程序最好单独建一个文件
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)