productcpp.docx

上传人:b****6 文档编号:9015595 上传时间:2023-02-02 格式:DOCX 页数:14 大小:16.03KB
下载 相关 举报
productcpp.docx_第1页
第1页 / 共14页
productcpp.docx_第2页
第2页 / 共14页
productcpp.docx_第3页
第3页 / 共14页
productcpp.docx_第4页
第4页 / 共14页
productcpp.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

productcpp.docx

《productcpp.docx》由会员分享,可在线阅读,更多相关《productcpp.docx(14页珍藏版)》请在冰豆网上搜索。

productcpp.docx

productcpp

#include

#include

usingnamespacestd;

classstudent

{

public:

stringplace;

intnumble;

stringname;

floatprice;

intyear;

intmonth;

intday;

intquantity;

student*next;

};

student*head=NULL;

voidaddgoods(student*head)//*增加商品功能*//

{

student*p=head;

stringname;

into,j;

cout<<"请输入你想要提取商品的名字"<

cin>>name;

system("cls");

if(head!

=NULL)

{

do

{

p=head;

head=head->next;

}while(p->name!

=name);

cout<<"请输入存入的数量"<

cin>>o;

j=p->quantity;

p->quantity=(j+o);

}

}

voidextract(student*head)//*提取功能*//

{

student*p=head;

stringname;

intl,j;

cout<<"请输入你想要提取商品的名字"<

cin>>name;

system("cls");

if(head!

=NULL)

{

do

{

p=head;

head=head->next;

}while(p->name!

=name);

cout<<''<<''<<""<<''<<"你想要提取的商品为:

"<<''<name<<""<<"库存量为:

"<<''<quantity<

cout<<""<

cout<<"请输入你想要提取的商品的数量"<

cin>>l;

if(l>(p->quantity))

{

cout<<''<<''<<""<<''<<"................................................"<

cout<<""<

cout<<''<<''<<""<<''<<"库存不够"<

cout<<""<

cout<<''<<''<<""<<''<<"请重新输入你想提取的数量,请不要超过库存量"<

cout<<""<

cout<<''<<''<<""<<''<<"请注意库存量为"<<''<quantity<

cout<<""<

cout<<''<<''<<""<<''<<"................................................"<

cout<<"请输入:

"<

cin>>l;

cout<<''<<''<<""<<''<<"提取成功"<

cout<<""<

j=p->quantity;

p->quantity=(j-l);

cout<<''<<''<<""<<''<<"库存剩余量为"<<''<quantity<

}

else

{

cout<<''<<''<<""<<''<<"提取成功"<

cout<<""<

l=p->quantity;

p->quantity=(p->quantity-l);

cout<<''<<''<<""<<''<<"库存剩余量为"<<''<quantity<

}

}

}

boolcheck(stringstr)//*判断输入*//

{

for(inti=0;i

{

if((str[i]<'0'||str[i]>'9')&&(str[i]!

='.'))

{

returnfalse;

}

}

returntrue;

}

student*create()

{

student*p1,*p2;

p1=newstudent;

head=p1;

p2=p1;

stringstr;

cout<<"请输入商品的编号"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入数字编号"<

cin>>str;

}

p1->numble=atoi(str.c_str());

if(p1->numble!

=0)

{

cout<<"请输入商品的名字:

"<

cin>>p1->name;

cout<<"请输入商品的价格"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入价格"<

cin>>str;

}

p1->price=atoi(str.c_str());

cout<<"请输入要存入的数量"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入存入数量"<

cin>>str;

}

p1->quantity=atoi(str.c_str());

cout<<"请输入商品的存储日期"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入年份"<

cin>>str;

}

p1->year=atoi(str.c_str());

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入月份"<

cin>>str;

}

p1->month=atoi(str.c_str());

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入day"<

cin>>str;

}

p1->day=atoi(str.c_str());

cout<<"请输入商品的产地"<

cin>>p1->place;

system("cls");

}

else

{

deletep1,p2=NULL,p2->next=NULL,head=NULL;

returnhead;

}

while(p1->numble!

=0)

{

p2=p1;

p1=newstudent;

cout<<"请输入商品的编号:

"<

cout<<"输入0代表退出存储功能"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入数字编号"<

cin>>str;

}

p1->numble=atoi(str.c_str());

if(p1->numble!

=0)

{

cout<<"请输入商品的名字:

"<

cin>>p1->name;

cout<<"请输入商品的价格"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入价格"<

cin>>str;

}

p1->price=atoi(str.c_str());

cout<<"请输入要存入的数量"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入存入数量"<

cin>>str;

}

p1->quantity=atoi(str.c_str());

cout<<"请输入商品的存储日期"<

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入年份"<

cin>>str;

}

p1->year=atoi(str.c_str());

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入月份"<

cin>>str;

}

p1->month=atoi(str.c_str());

cin>>str;

while(!

check(str))

{

cout<<"输入错误,请重新输入day"<

cin>>str;

}

p1->day=atoi(str.c_str());

cout<<"请输入商品的产地"<

cin>>p1->place;

system("cls");

p2->next=p1;

}

}

deletep1,p2->next=NULL;

returnhead;

}

voidinsert(student*head)

{

intnum=0;

stringname;

student*p=NULL;

student*l;

p=newstudent;

while(head)

{

l=head;

head=head->next;

}

l->next=p;

p->next=NULL;

cout<<"请输入插入的内容:

"<

cout<<"请输入商品的名字"<

cin>>p->name;

cout<<"请输入商品的编号"<

cin>>p->numble;

cout<<"请输入商品的价格"<

cin>>p->price;

cout<<""<

cin>>p->quantity;

cout<<"请输入商品的存储日期"<

cin>>p->year;

cin>>p->month;

cin>>p->day;

cout<<"请输入商品的产地"<

cin>>p->place;

cout<<"添加成功"<

cout<<""<

}

voiddeletenode(student*head)//*删除功能*//

{

student*l=NULL;

intnum;

cout<<"请输入你想删除的编号"<

cin>>num;

if(head->numble==num)

{

l=head;

head=head->next;

:

:

head=head;

deletel;

return;

}

while(head!

=NULL)

{

if(head->next==NULL)

{

cout<<"没找到要删除的编号"<

cout<<""<

return;

}

if(head->next->numble==num)

{

l=head->next;

head->next=l->next;

deletel;

cout<<"成功删除"<

cout<<""<

return;

}

head=head->next;

}

}

voidshow(student*beginhead)//*显示功能*//

{

student*p=beginhead;

do

{

if(beginhead!

=NULL)

{

cout<<''<<''<<""<<''<<"商品的编号为:

"<<''<numble<<""<<"商品的名字为:

"<<''<name<

cout<<""<

cout<<''<<''<<""<<''<<"商品的价格为:

"<<''<price<<""<<"商品的产地为:

"<<''<place<

cout<<""<

cout<<''<<''<<""<<''<<"商品的库存数量为:

"<<''<quantity<<""<<"商品的存储日期为:

"<year<<'-'<month<<'-'<day<

cout<<''<<''<<""<<''<<"......................................."<

cout<<''<

p=p->next;

}

else

{

cout<<"此链表为空"<

deletep;

}

}

while(p!

=NULL);

}

voidsearch(student*head)//*查询*//

{

intnum;

student*p;

cout<<"请输入你想查找的编号:

"<

cin>>num;

while(head)

{

if(head->next==NULL)

{

cout<<"没找到要查询的编号"<

return;

}

if(head->numble==num)

{

p=head;

cout<<"商品的名字为;"<<''<name<

cout<<"商品编号为:

"<<''<numble<

cout<<"商品的价格为:

"<<''<price<

cout<<"商品的库存数量为:

"<<''<quantity<

cout<<"商品的存储日期为:

"<<''<year<<'-'<month<<'-'<day<

cout<<"商品的产地为:

"<<''<place<

return;

}

else

{

head=head->next;

p=head;

}

}

}

intmain()//*系统入口主函数*//

{

inti,k;

cout<<''<<''<<""<<''<<""<<"欢迎进入仓库管理系统"<

do

{

cout<<""<

cout<<""<

cout<<''<<''<<""<<''<<""<<"............................."<

cout<<""<

cout<<''<<''<<""<<''<<""<<"1代表存储商品基本信息."<

cout<<""<

cout<<''<<''<<""<<''<<""<<"2代表删除商品基本信息."<

cout<<""<

cout<<''<<''<<""<<''<<""<<"3代表显示所有商品信息."<

cout<<""<

cout<<''<<''<<""<<''<<""<<"4代表查询商品基本信息."<

cout<<""<

cout<<''<<''<<""<<''<<""<<"5代表添加商品基本信息."<

cout<<""<

cout<<''<<''<<""<<''<<""<<"6代表提取商品."<

cout<<""<

cout<<''<<''<<""<<''<<""<<"7代表增加已有商品的存储量"<

cout<<""<

cout<<''<<''<<""<<''<<""<<"............................."<

cout<<""<

cout<<""<<"请选择功能:

";

cin>>i;

system("cls");

switch(i)

{

case1:

head=create();break;

case2:

deletenode(head);break;

case3:

show(head);break;

case4:

search(head);break;

case5:

insert(head);break;

case6:

extract(head);break;

case7:

addgoods(head);break;

}

cout<<"是否继续选择功能?

"<

cout<<"1代表是,0代表否"<

cout<<"按1将自动跳转回功能选择界面"<

cin>>k;

system("cls");

}

while(k!

=0);

return0;

}

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

当前位置:首页 > 高等教育 > 研究生入学考试

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

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