- 8
- 0
- 约2.99千字
- 约 4页
- 2015-09-13 发布于重庆
- 举报
电视机管理系统(数据库基础C编程),数据库管理系统,数据库管理系统有哪些,什么是数据库管理系统,数据库管理系统软件,关系数据库管理系统,数据库图书管理系统,数据库管理系统是,学生管理系统数据库,数据库图书馆管理系统
#includeiostream
#includestring
#includemalloc.h
using namespace std;
struct Node
{char name[10];
float price;
int num;
struct Node *next;
};
struct Link
{Node *head;
int len;
};
int search(Link Q,Node *p)
{
Node *q;
int i=0;
for(q=Q.head;q-next;q=q-next,i++){
if((strcmp(q-name,p-name)==0)){
cout品牌q-nameendl价格q-priceendl数量q-numendl;
return i;}
if(p-price==q-price||p-num==q-num)cout品牌q-nameendl价格q-priceendl数量q-numendl;
if(p-priceq-price)return i;
}
return i;
}
void increase(Link Q,int i,Node *p)
{
Node *q;
for(q=Q.head;i0;i--,q=q-next);
if(strcmp(q-name,p-name)==0)q-num+=p-num;
else {p-next=q-next;q-next=p;Q.len++;}
}
void jianli(Link Q)
{Q.head=(Node *)malloc(sizeof(Node));
Node *p;
if(!Q.head)exit(1);
p=Q.head;
strcpy(p-name,);Q.head-price=0.0;Q.head-num=0;Q.head-next=NULL;
p=(Node*)malloc(sizeof(Node));
cout请输入电视机的品牌,价格,数量:endl;
cinp-namep-pricep-num;
while(p-num!=0)
{
increase(Q,search(Q,p),p);
p=(Node*)malloc(sizeof(Node));
cinp-namep-pricep-num;
}
}
void decrease(Link Q,Node *p)
{
Node *q;
for(q=Q.head;q-next;q=q-next)
if(strcmp(q-next-name,p-name)==0)break;
if(q-next-num==p-num)
{cout该电视机已销售完!endl;
q-next=q-next-next;Q.len--;
}
else q-next-num-=p-num;
}
void ruku(Link Q)
{
Node *p;
p=(Node*)malloc(sizeof(Node));
cout请输入电视机的品牌,价格,数量:endl;
cinp-namep-pricep-num;
while(p-num!=0)
{
increase(Q,search(Q,p),p);
p=(Node*)malloc(sizeof(Node));
cinp-namep-pricep-num;
}
}
void chuku(Link Q)
{
Node *p;
p=(Node*)malloc(sizeof(Node));
cout请输入电视机的品牌,价格,数量:endl;
cinp-namep-pricep-num;
while(p-num!=0)
{
decrease(Q,p);
p=(Node*)malloc(sizeof(Node));
cinp-namep-pricep-num;
}
}
void chaxun(Link Q)
{
Node *p;
int i;
p=(Node*)malloc(sizeof(Node));
cout查找方式:endl1.按品牌endl2.按价格endl3.按数量endl;
cout请输入你按何种方式查询:endl;
cini;
switch(i)
{case 1:cout请输入品牌:endl;cinp-name; while(strcmp(p-name,)!=0){p-price=0.0;p-num=0;search(Q,p);}break;
case 2:cout请输入价格:endl;cinp-price; while(p-price!=0)strcpy(p-name,);p-nu
原创力文档

文档评论(0)