当前位置:首页 » 编程语言 » c语言更改库存信息的代码
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言更改库存信息的代码

发布时间: 2022-10-07 19:01:45

c语言图书信息管理系统加一个功能:显示出不同图书的库存量。代码怎么改急!

数据库或者文件里加一个变量用于存储就行了

Ⅱ c语言程序设计 用链表编写商品库存管理。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node{
char no[20];//存放编号
char name[40];//存放名称
int reserve;//库存
struct node *next;
}NODE;

typedef struct link{
NODE *front;//头指针
NODE *rear;//尾指针
}LINK;

NODE *create_node(void){
NODE *node = (NODE *)malloc(sizeof(NODE));
printf("请输入货物编号:");
gets(node->no);
printf("请输入货物名称:");
gets(node->name);
printf("请输入货物名称:");
char ch;
while( (ch= getchar()) != '\n');//rewind(stdin);
scanf("%d",&node->reserve);
node->next = NULL;
return node;
}

void init_link(LINK *link){
link->rear = NULL;
link->front = NULL;
}

int link_empty(LINK *link){
return link->front == NULL ? 1: 0;
}

int node_num(LINK *link){
int num = 0;
if( link_empty(link)){
return num;
}
num = 1;
NODE *node = link->front;
while(node != link->rear){
node = node->next;
++num;
}
return num;
}

/*NODE *node_find(LINK *link,const int n){
int num = node_num(link);
if(num < n){
printf("公有节点%d个,无法找到第%d个节点\n",num,n);

}
else{

}
}
*/
void node_push(LINK *link){
NODE *node = create_node();
if(link->front == NULL){
link->front = node;
link->rear = node;
node->next = NULL;
}
else{
link->rear->next = node;
link->rear = node;
node->next = NULL;
}
}

void node_insert(LINK *link,const int n){
int num = 0,i = 1;
NODE *node = link->front;
NODE *new_node = NULL;
if ( link_empty(link) ){
printf("链表为空,将建立链表!\n");
node_push(link);
}
else{
if( n <= 1){
printf("在链表头插入数据\n");
new_node = create_node();
new_node->next = link->front;
link->front = new_node;
}
else if( n>= num = node_num(link) ){
printf("节点数少于%d,将在末尾插入节点.\n",n);
node_push(link);
}
else{
printf("在第n个节点后插入数据\n");
if(num >= n){
while( i != n){
node = node->next;
++i;
}
new_node = create_node();
new_node-next = node->next;
node->next = new_node;
}
}
}

void find_node_insert(LIKNK *link,const char *name){
NODE *node = link->front;
if( link_empty(link) )
node_push(link);
else {
while(strcmp(node->name,name) != 0){
if(node != link->rear)
node = node->next;
else break;

}
if(node != NULL){

NODE *new_node = create_node();
new_node-next = node->next;
node->next = new_node;
}
else {
printf("没有找到相关货物,将在头节点插入数据\n");
intsert(link,0);
}
}

/*由于我不知到你对货物统计具体实现的要求,关于货物数量统计就你自己写了,应该比较简单。*/
/* 代码没有具体运行过,如果你学过C结构体与指针,就这个代码思路应该看得明白,真正的实现你自己实现吧
这样对你会更好写。可能会有错误的地方,请谨慎。 */

Ⅲ 谁知道用c语言向数据库做增删改查吗

我曾经写过C语言的数据库系统..
给你部分代码(一个销售函数)以作参考...
void
book_out()
//销售函数
{
char
temp;
EXEC
SQL
BEGIN
DECLARE
SECTION;
/*主变量定义开始.*/
int
Hout_shuliang;
int
Hshuliang;///////////
char
Hbook_id[11];
EXEC
SQL
END
DECLARE
SECTION;
/*主变量定义结束*/
lab3:
printf("请输入图书编号:");
scanf("%s",&Hbook_id);
printf("请输入卖出本数:");
scanf("%d",&Hout_shuliang);
//先将库存量取出到主变量
EXEC
SQL
select
book_shuliang
into
:Hshuliang
from
book_kucun
where
book_id=:Hbook_id;
if(Hshuliang<Hout_shuliang)
//假如库存不足,销售不成功.
{
printf("输入有误.没那么多库存,请重新输入.\n");
goto
lab3;
}
//将销售记录插入到book_out(销售表)数据表.
EXEC
SQL
insert
into
book_out
values(:Hbook_id,:Hout_shuliang,GETDATE());
EXEC
SQL
COMMIT
TRANSACTION;
/*事务提交*/
printf("售出成功,输入Y继续输入其他要售出的书.其他键返回主菜单:");
getchar();//////////////////////////
scanf("%c",&temp);
if(temp=='y'||temp=='Y')
goto
lab3;
}

Ⅳ c语言仓库管理系统源代码

学籍管理的程序,你自己改改吧
#include<stdio.h>
#include<windows.h>
#include<conio.h>
int add();
int amend();
int remove();
int show_student();
int show_class();
struct info //定义结构体info,用于存储学生信息
{
char name[20]; //姓名
char sex[20]; //性别
char idcard[20]; //身份证号码
char stuid[10]; //学号
char academe[20]; //学院
char specialty[20]; //专业
char classid[20]; //班级
char home[20]; //生源地
}stu[100];
int j=0;
int main(void) //主函数
{
/*登陆界面设计*/
char gongnengxuanzhe;
int flag=1;
system("cls");
printf("\n");
printf("\t\t\t\t 欢迎\n");
printf("\n\n\t尊敬的用户, 非常感谢您使用本系统 , 您的完美体验将是我们前进的方向 !\n\n\n");
printf("\t系统功能简介:\n\n\n");
printf("\t\t①:通过键盘输入某位学生的学生证信息。\n\n");
printf("\t\t②:给定学号,显示某位学生的学生证信息。\n\n");
printf("\t\t③:给定某个班级的班号,显示该班所有学生的学生证信息。\n\n");
printf("\t\t④:给定某位学生的学号,修改该学生的学生证信息。\n\n");
printf("\t\t⑤:给定某位学生的学号,删除该学生的学生证信息。\n\n");
printf("\t\t⑥:按出生日期对全班学生的信息进行排序。\n\n\n");
printf("\t按任意键进入系统......");
getch();
do
{
system("cls");
printf("\n\n\n");
printf(" 尊敬的用户 ,欢迎您使用本系统 !\n");
printf("\n\n\n");
printf(" 1.增加学生信息\n\n");
printf(" 2.修改学生信息\n\n");
printf(" 3.删除学生信息\n\n");
printf(" 4.显示单个学生信息\n\n");
printf(" 5.显示整个班级学生信息\n\n");
printf(" 0.退出系统\n\n\n\n");
printf(" 请选择您需要使用的功能:");
gongnengxuanzhe=getch();
switch(gongnengxuanzhe)
{
case '1':add();break;
case '2':amend();break;
case '3':remove();break;
case '4':show_student();break;
case '5':show_class();break;
case '0':flag=0;break;
default:
{
printf("\n\n 您的输入有误,请仔细阅读使用说明!");
printf("\n 任意键继续...");
getch();
}

}
}while(flag==1);
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t尊敬的用户,非常感谢您的使用,您对于完美的追求是我们唯一的动力!");
printf("\n\n\t\t\t 按任意键退出系统......");
getch();
return 0;
}
int add() //增加学生信息函数
{
char flag='1';
do
{
system("cls");
printf("\n\t姓名:");
scanf("%s",&stu[j].name);
printf("\n\n\t性别:");
scanf("%s",&stu[j].sex);
printf("\n\n\t身份证号:");
scanf("%s",&stu[j].idcard);
printf("\n\n\t学院:");
scanf("%s",&stu[j].academe);
printf("\n\n\t专业:");
scanf("%s",&stu[j].specialty);
printf("\n\n\t班级:");
scanf("%s",&stu[j].classid);
printf("\n\n\t学号:");
scanf("%s",&stu[j].stuid);
printf("\n\n\t生源地:");
scanf("%s",&stu[j].home);
j++;
printf("\n\t继续增加请键入1,返回请键入其他任意键:");
getchar();
flag=getchar();
}while(flag=='1');
return 0;
}
int amend() //修改学生信息函数
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系统无任何可以修改的记录,请先行输入数据!");
printf("\n\n\t\t\t 按任意键返回......");
getch();
return 0;
}
char a[20];
int z;
int flag=0;
do
{
system("cls");
printf("\n\t需要修改的学生学号:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].stuid,a)==0)
{
flag=1;
break; //break退出后,z++不会执行
}
}
if(flag==0)
{
printf("\t对不起,你请求学生信息不存在,请核实后重试!\n");
printf("\t按任意键继续......");
getch();
}
}while(flag==0);
system("cls");
printf("\n\t姓名:");
scanf("%s",&stu[z].name);
printf("\n\n\t性别:");
scanf("%s",&stu[z].sex);
printf("\n\n\t身份证号:");
scanf("%s",&stu[z].idcard);
printf("\n\n\t学院:");
scanf("%s",&stu[z].academe);
printf("\n\n\t专业:");
scanf("%s",&stu[z].specialty);
printf("\n\n\t班级:");
scanf("%s",&stu[z].classid);
printf("\n\n\t学号:");
scanf("%s",&stu[z].stuid);
printf("\n\n\t生源地:");
scanf("%s",&stu[z].home);
return 0;
}
int remove() //删除学生信息函数
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系统无任何可以删除的记录,请先行输入数据!");
printf("\n\n\t\t\t 按任意键返回......");
getch();
return 0;
}
char a[20];
int z;
int x;
int flag=0;
do
{
system("cls");
printf("\n\t需要删除的学生学号:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].stuid,a)==0)
{
flag=1;
for(x=z;x<j;x++)
{
strcpy(stu[x].name,stu[x+1].name);
strcpy(stu[x].sex,stu[x+1].sex);
strcpy(stu[x].idcard,stu[x+1].idcard);
strcpy(stu[x].academe,stu[x+1].academe);
strcpy(stu[x].specialty,stu[x+1].specialty);
strcpy(stu[x].classid,stu[x+1].classid);
strcpy(stu[x].stuid,stu[x+1].stuid);
strcpy(stu[x].stuid,stu[x+1].stuid);
}
j--;
printf("\n\t删除成功!");
printf("\n\t按任意键返回上级菜单......");
getch();
}
}
if(flag==0)
{
printf("\t对不起,你请求学生信息不存在,请核实后重试!\n");
printf("\t按任意键继续......");
getch();
}
}while(flag==0);
return 0;
}
int show_student() //单个显示学生信息函数
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系统无任何可以显示的记录,请先行输入数据!");
printf("\n\n\t\t\t 按任意键返回......");
getch();
return 0;
}
char a[20];
int z;
int flag=0;
do
{
system("cls");
printf("\n\t需要显示的学生学号:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].stuid,a)==0)
{
flag=1;
system("cls");
printf("\n\t姓名:%s",stu[z].name);
printf("\n\n\t性别:%s",stu[z].sex);
printf("\n\n\t身份证号:%s",stu[z].idcard);
printf("\n\n\t学院:%s",stu[z].academe);
printf("\n\n\t专业:%s",stu[z].specialty);
printf("\n\n\t班级:%s",stu[z].classid);
printf("\n\n\t学号:%s",stu[z].stuid);
printf("\n\n\t生源地:%s",stu[z].home);
printf("\n\n\t按任意键返回上级菜单......");
getch();
}
}
if(flag==0)
{
printf("\t对不起,你请求显示的学生信息不存在,请核实后重试!\n");
printf("\t按任意键继续......");
getch();
}
}while(flag==0);
return 0;
}
int show_class() //显示整个班级学生信息函数
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系统无任何可以显示的记录,请先行输入数据!");
printf("\n\n\t\t\t 按任意键返回......");
getch();
return 0;
}
char a[20];
int z;
int x;
int flag=0;
do
{
system("cls");
printf("\n\t需要显示的班级号码:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].classid,a)==0)
{
flag=1;
system("cls");
printf("\t%s %s 基本信息\n",stu[z].specialty,stu[z].classid);
for(x=0;x<j;x++)
{
if(strcmp(stu[x].classid,a)==0)
{
printf("\n\n\t姓名:%s",stu[z].name);
printf("\n\t性别:%s",stu[z].sex);
printf("\n\t身份证号:%s",stu[z].idcard);
printf("\n\t学院:%s",stu[z].academe);
printf("\n\t专业:%s",stu[z].specialty);
printf("\n\t班级:%s",stu[z].classid);
printf("\n\t学号:%s",stu[z].stuid);
printf("\n\t生源地:%s",stu[z].home);
}
}
printf("\n\n\t按任意键返回上级菜单......");
getch();
}
}
if(flag==0)
{
printf("\t对不起,你请求显示的班级信息不存在,请核实后重试!\n");
printf("\t按任意键继续......");
getch();
}
}while(flag==0);
return 0;
}
有疑问联系我,[email protected]
请采纳。

Ⅳ .求用c语言写的源代码。。。图书管理系统 系统功能主要是管理图书的库存信息、图书的借阅信息以及借阅

额额,你这个程序够复杂的啊
这样的程序,一般都是定制写的
网上很少有完全符合要求的啊
所以,我做程序编程的,主要做C语言的,可以搞定的啊哈
只不过哈,无利不起早啊
嘎嘎

Ⅵ c语言图书库存管理系统

#include<algorithm>#include<cstdio>#include<cstring>#include<cstdlib>#include<iostream>#include<vector>#include<queue>#include<stack>#include<map>#include<string>#include<climits>#include<cmath>#define N 1000010#define LL long longusing namespace std;#include<iostream>#include<iomanip>#include<string>#include<fstream>#include<stdio.h>using namespace std;const int Maxb=10000; //最多的图书class Book//图书类{int tag; //删除标记:已删0:未删int number; //ISBN书号char name[20]; //书名char author[10]; //主编char number2[10];//版次char position[20];//出版社char time[20];//出版年int price;//定价int onshelf; //是否在架1:在架0:已借public:Book() {}char *getname() { return name; } //获取姓名int getnumber() { return number; } //获取ISBN书号int gettag() { return tag; } //获取删除标记char *getauthor() {return author;} //获取主编char *getnumber2() {return number2;} //获取版次char *getposition() {return position;} //获取出版社char *gettime() {return time;} //获取出版年char getprice() {return price;} //获取图书定价void delbook() { tag=1; } //删除图书void addbook(int n,char *na,char *au,char *n2,char *da,char *ti,int pr) //增加图书{tag=0;number=n;price=pr;strcpy(name,na);strcpy(author,au);strcpy(number2,n2);strcpy(position,da);strcpy(time,ti);onshelf=1;} void disp() //输出图书{cout << setw(10) << number << setw(10) << name << setw(10)<< setw(10)<<author<<setw(10)<<number2<<setw(10)<<position<<setw(10)<<time<<setw(10)<<price<<endl;}}; class BDatabase //图书库类{int top; //图书记录指针Book book[Maxb]; //图书记录public:BDatabase() //构造函数,将book.txt读到book[]中{Book b;top=-1;fstream file("book.txt",ios::in);while (1){file.read((char *)&b,sizeof(b));if (!file) break;top++;book[top]=b;}file.close();} void clear() //全删{top=-1;} int addbook(int n,char *na,char *au, char *n2, char *da,char *ti,int pr) //增加图书{Book *p=search1(n);if (p==NULL){top++;book[top].addbook(n,na,au,n2,da,ti,pr);return 1;}return 0;} Book *search1(int bookid) //查找图书{for (int i=0;i<=top;i++)if (book[i].getnumber()==bookid &&book[i].gettag()==0)return &book[i];return NULL;} Book *search2(int bookid,char *name) //按书名查找图书{ for(int i=0;i<=top;i++) if(strcmp(book[i].getname(),name)==0) {bookid=book[i].getnumber(); return &book[i]; } return NULL;} Book *search3(int bookid,char *author) //按主编查找图书{ for(int i=0;i<=top;i++) if(strcmp(book[i].getauthor(),author)==0) {bookid=book[i].getnumber(); return &book[i]; } return NULL;} void bookdata(); //图书库维护 void disp(){ cout<<setw(10)<<"图书书号"<<setw(10)<<"图书名字"<<setw(10)<<"图书主编"<<setw(10)<<"版次"<<setw(10)<<"出版社"<<setw(10)<<"出版年"<<setw(10)<<"价格"<<endl<<endl<<endl<<endl;for (int i=0;i<=top;i++)if (book[i].gettag()==0)book[i].disp();}~BDatabase() //析构函数,将book[]写入book.txt文件中{fstream file("book.txt",ios::out);for (int i=0;i<=top;i++)if (book[i].gettag()==0)file.write((char *)&book[i],sizeof(book[i]));file.close();}}; void BDatabase::bookdata(){int choice=1;int choice2=1;int choice3=1;int choice4;char bname[40];char editor[40];char banci[40];char position[40];char year[40];int value;int bookid;Book *b;while (choice!=0){ cout<<endl<<endl;cout<<" **************************** "<<endl;cout<<" **** 1添加图书 **** "<<endl;cout<<" **** 3 删除图书 **** "<<endl;cout<<" **** 4 图书查询 **** "<<endl;cout<<" **** 5 显示图书 **** "<<endl;cout<<" **** 6 全部删除 **** "<<endl;cout<<" **** 7 借书 **** "<<endl;cout<<" **** 8 还书 **** "<<endl;cout<<" **** 0 退出 **** "<<endl;cout<<" ****************************"<<endl<<endl;cout<<endl<<"请按键选择您需要的操作:";cin>>choice;while(choice!=1&&choice!=2&&choice!=3&&choice!=4&&choice!=5&&choice!=6&&choice!=0){ cout<<endl<<" ** 您输入的编号在菜单里不存在,请重新输入 **"<<'\a'<<endl<<endl; cout<<" 请选择您需要的操作:"; cin>>choice;} switch (choice){case 1:cout <<"输入ISBN书号(一定为数字否则会异常):";cin >> bookid; cout <<"输入书名:";cin >> bname; cout <<"输入主编:";cin >>editor;cout <<"输入版次(一定为数字否则会异常):";cin>>banci;cout<<"输入出版社:";cin>>position;cout<<"输入出版年(一定为数字否则会异常):"; cin>>year;cout<<"输入价格(一定为数字否则会异常):";cin>>value;addbook(bookid,bname,editor,banci,position,year,value);cout<<"ISBN书号"<<bookid<<"添加成功,如需返回主菜单请按1,退出系统请按0(一定要输入数字)";cin>>choice4;while (choice4!=0&&choice4!=1){ cout<<"输入错误请重新输入"<<endl; cin>>choice4;}switch (choice4){case 1:choice=1;break;case 0: choice=0; break;}break; case 3:cout << " 输入ISBN书号:";cin >> bookid;b=search1(bookid);if (b==NULL){cout << " 该图书不存在" << endl;break;}b->delbook();break;case 4: cout<<"查找方式:"<<endl<<"1按ISBN书号查询 2按书名查询 3按主编查询 0退出:"; cin>>choice3;switch(choice3){case 1: {cout << " 输入ISBN书号:"; //按ISBN书号查询cin >> bookid;b=search1(bookid);if (b==NULL){cout << " 该图书不存在" << endl;break;}b->disp();}break;case 2:{ cout<<"请输入书名:"; cin>>bname; b=search2(bookid,bname); if(b==NULL) { cout<<"该图书不存在啊!"<<endl; break; } b->disp();} break;case 3: { cout<<"请输入主编:"; cin>>editor; b=search3(bookid,editor); if(b==NULL) { cout<<"该主编不存在!"<<endl; break; } b->disp();} break;}break;case 5:disp();break;case 6:clear();break;}}cout<<endl<<" ****** 慢走 ******"<<endl<<endl<<endl;}; int main(){BDatabase BookDB;cout<<endl<<endl<<endl;cout<<" Welcome to the library of SCU "<<endl;cout<<" 欢 迎 来 到XXXX 大 学 图 书 馆 "<<endl;cout<<endl<<endl<<"请输入0进入图书馆"<<endl;int w;cin>>w;if(w==0)BookDB.bookdata();system("pause");return 0;}

Ⅶ c语言图书信息管理系统 在不影响原本功能的前提下,显示出不同书的库存量,这代码该怎么改急急急!

那要看你怎么储存了图书信息,要把代码贴出来。

Ⅷ 用C语言编写大学图书库存管理系统 若答案合适 可再给100分

好了,希望能够帮到您。

如果你真的要纯c的话,只需要改一下输入输出就可。

即:cin,cout改为scanf,printf。

//MemoryTime
//1347K0MS
//by:Snarl_jsb
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<climits>
#include<cmath>
#defineN1000010
#defineLLlonglong
usingnamespacestd;
#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
#include<stdio.h>
usingnamespacestd;
constintMaxb=10000;//最多的图书
classBook//图书类
{
inttag;//删除标记1:已删0:未删
intnumber;//ISBN书号
charname[20];//书名
charauthor[10];//主编
charnumber2[10];//版次
charposition[20];//出版社
chartime[20];//出版年
intprice;//定价
intonshelf;//是否在架1:在架0:已借
public:
Book(){}
char*getname(){returnname;}//获取姓名
intgetnumber(){returnnumber;}//获取ISBN书号
intgettag(){returntag;}//获取删除标记
char*getauthor(){returnauthor;}//获取主编
char*getnumber2(){returnnumber2;}//获取版次
char*getposition(){returnposition;}//获取出版社
char*gettime(){returntime;}//获取出版年
chargetprice(){returnprice;}//获取图书定价
voiddelbook(){tag=1;}//删除图书
voidaddbook(intn,char*na,char*au,char*n2,char*da,char*ti,intpr)//增加图书
{
tag=0;
number=n;
price=pr;
strcpy(name,na);
strcpy(author,au);
strcpy(number2,n2);
strcpy(position,da);
strcpy(time,ti);
onshelf=1;
}voiddisp()//输出图书
{
cout<<setw(10)<<number<<setw(10)<<name<<setw(10)
<<setw(10)<<author<<setw(10)<<number2<<setw(10)<<position<<setw(10)<<time<<setw(10)<<price<<endl;
}
};

classBDatabase//图书库类
{
inttop;//图书记录指针
Bookbook[Maxb];//图书记录
public:
BDatabase()//构造函数,将book.txt读到book[]中
{
Bookb;
top=-1;
fstreamfile("book.txt",ios::in);
while(1)
{
file.read((char*)&b,sizeof(b));
if(!file)break;
top++;
book[top]=b;
}
file.close();
}


voidclear()//全删
{
top=-1;
}


intaddbook(intn,char*na,char*au,char*n2,char*da,char*ti,intpr)//增加图书
{
Book*p=search1(n);
if(p==NULL)
{
top++;
book[top].addbook(n,na,au,n2,da,ti,pr);
return1;
}
return0;
}


Book*search1(intbookid)//查找图书
{
for(inti=0;i<=top;i++)
if(book[i].getnumber()==bookid&&
book[i].gettag()==0)
return&book[i];
returnNULL;
}


Book*search2(intbookid,char*name)//按书名查找图书
{
for(inti=0;i<=top;i++)
if(strcmp(book[i].getname(),name)==0)
{bookid=book[i].getnumber();
return&book[i];
}

returnNULL;
}

Book*search3(intbookid,char*author)//按主编查找图书
{
for(inti=0;i<=top;i++)
if(strcmp(book[i].getauthor(),author)==0)
{bookid=book[i].getnumber();
return&book[i];
}

returnNULL;
}

voidbookdata();//图书库维护

voiddisp()
{
cout<<setw(10)<<"图书书号"<<setw(10)<<"图书名字"<<setw(10)<<"图书主编"<<setw(10)<<"版次"<<setw(10)<<"出版社"<<setw(10)<<"出版年"<<setw(10)<<"价格"<<endl<<endl<<endl<<endl;
for(inti=0;i<=top;i++)
if(book[i].gettag()==0)
book[i].disp();
}
~BDatabase()//析构函数,将book[]写入book.txt文件中
{
fstreamfile("book.txt",ios::out);
for(inti=0;i<=top;i++)
if(book[i].gettag()==0)
file.write((char*)&book[i],sizeof(book[i]));
file.close();
}
};

voidBDatabase::bookdata()
{
intchoice=1;
intchoice2=1;
intchoice3=1;
intchoice4;
charbname[40];
chareditor[40];
charbanci[40];
charposition[40];
charyear[40];
intvalue;
intbookid;
Book*b;
while(choice!=0)
{
cout<<endl<<endl;
cout<<"****************************"<<endl;
cout<<"****1添加图书****"<<endl;
cout<<"****3删除图书****"<<endl;
cout<<"****4图书查询****"<<endl;
cout<<"****5显示图书****"<<endl;
cout<<"****6全部删除****"<<endl;
cout<<"****7借书****"<<endl;
cout<<"****8还书****"<<endl;
cout<<"****0退出****"<<endl;
cout<<"****************************"<<endl<<endl;
cout<<endl<<"请按键选择您需要的操作:";
cin>>choice;
while(choice!=1&&choice!=2&&choice!=3&&choice!=4&&choice!=5&&choice!=6&&choice!=0){
cout<<endl<<"**您输入的编号在菜单里不存在,请重新输入**"<<'a'<<endl<<endl;
cout<<"请选择您需要的操作:";
cin>>choice;
}

switch(choice)
{
case1:
cout<<"输入ISBN书号(一定为数字否则会异常):";
cin>>bookid;
cout<<"输入书名:";
cin>>bname;
cout<<"输入主编:";
cin>>editor;
cout<<"输入版次(一定为数字否则会异常):";
cin>>banci;
cout<<"输入出版社:";
cin>>position;
cout<<"输入出版年(一定为数字否则会异常):";
cin>>year;
cout<<"输入价格(一定为数字否则会异常):";
cin>>value;
addbook(bookid,bname,editor,banci,position,year,value);
cout<<"ISBN书号"<<bookid<<"添加成功,如需返回主菜单请按1,退出系统请按0(一定要输入数字)";
cin>>choice4;
while(choice4!=0&&choice4!=1)
{
cout<<"输入错误请重新输入"<<endl;
cin>>choice4;}
switch(choice4)
{
case1:
choice=1;
break;
case0:
choice=0;
break;}
break;


case3:
cout<<"输入ISBN书号:";
cin>>bookid;
b=search1(bookid);
if(b==NULL)
{
cout<<"该图书不存在"<<endl;
break;
}
b->delbook();
break;
case4:
cout<<"查找方式:"<<endl<<"1按ISBN书号查询2按书名查询3按主编查询0退出:";
cin>>choice3;
switch(choice3)
{
case1:
{cout<<"输入ISBN书号:";//按ISBN书号查询
cin>>bookid;
b=search1(bookid);
if(b==NULL)
{
cout<<"该图书不存在"<<endl;
break;
}
b->disp();
}
break;
case2:
{
cout<<"请输入书名:";
cin>>bname;
b=search2(bookid,bname);
if(b==NULL)
{
cout<<"该图书不存在啊!"<<endl;
break;
}
b->disp();
}

break;
case3:
{
cout<<"请输入主编:";
cin>>editor;
b=search3(bookid,editor);
if(b==NULL)
{
cout<<"该主编不存在!"<<endl;
break;
}
b->disp();
}
break;
}
break;
case5:
disp();
break;
case6:
clear();
break;
}
}
cout<<endl<<"******慢走******"<<endl<<endl<<endl;
};

intmain()
{
BDatabaseBookDB;
cout<<endl<<endl<<endl;
cout<<"WelcometothelibraryofSCU"<<endl;
cout<<"欢迎来到四川大学图书馆"<<endl;
cout<<endl<<endl<<"请输入0进入图书馆"<<endl;
intw;
cin>>w;
if(w==0)
BookDB.bookdata();
system("pause");
return0;
}

Ⅸ 商品库存管理系统的c语言源代码

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

struct BOOK
{
int id,usr[10],total,store,days[10];
char name[31],author[21];
}books[100];
/*上面是结构体的定义,用于存放书籍及借书的信息。*/

void page_title(char *menu_item)
{
clrscr();
printf(">>> 图 书 管 理 系 统 <<<\n\n- %s -\n\n",menu_item);
}
/*上面是打印页眉的函数,同时通过参数menu_item,可以显示当前的状态。*/

void return_confirm(void)
{
printf("\n按任意键返回……\n");
getch();
}
/*上面是返回前请求确认的函数,以便在返回前观察结果*/

int search_book(void)
{
int n,i;
printf("请输入图书序号:");
scanf("%d",&i);
for(n=0;n<100;n++)
{
if(books[n].id==i)
{
printf("书名:%s\n",books[n].name);
printf("作者:%s\n",books[n].author);
printf("存数:%d of ",books[n].store);
printf("%d\n",books[n].total);
return n;
}
}
printf("\n输入错误或无效图书序号.\n");
return -1;
}
/*上面的函数是在数组中找到图书号匹配的记录,显示其信息并返
回数组下标,如果找不到相应记录则提示错误并返回-1。*/

void book_out(void)
{
int n,s,l,d;
page_title("借阅图书");
if((n=search_book())!=-1&&books[n].store>0)
{
printf("请输入借书证序号:");
scanf("%d",&s);
printf("请输入可借天数:");
scanf("%d",&d);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==0)
{
books[n].usr[l]=s;
books[n].days[l]=d;
break;
}
}
books[n].store--;
}
if(n!=-1&&books[n].store==0) printf("此书已经全部借出.\n");
return_confirm();
}
/*上面是借书的函数,首先调用找书函数*/

void book_in(void)
{
int n,s,l;
page_title("归还图书");
if((n=search_book())!=-1&&books[n].store<books[n].total)
{
printf("借阅者图书证列表:\n");
for(l=0;l<10;l++)
if (books[n].usr[l]!=0)
printf("[%d] - %d天\n",books[n].usr[l],books[n].days[l]);
printf("请输入借书证序号:");
scanf("%d",&s);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==s)
{
books[n].usr[l]=0;
books[n].days[l]=0;
break;
}
}
books[n].store++;
}
if(n!=-1&&books[n].store==books[n].total)
printf("全部入藏.\n");
return_confirm();
}

void book_add(void)
{
int n;
page_title("注册新书");
for(n=0;n<100;n++)
if(books[n].id==0) break;
printf("序号:");
scanf("%d",&books[n].id);

Ⅹ c语言设计实现一个简单库存管理程序编程

我有一个学生管理系统程序,你可以把学生量改成库存量。
希望对你能有帮助。http://..com/question/2202293700663164948.html?oldq=1