📄 register.c
字号:
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<stdlib.h>
#include<conio.h>
#include"Register.h"
linklist * Initialize(void)
{
int n=0;
int nnum_of_goods;
int nprise;
char ntype[LENGTH];
char ch1,ch2;
linklist *temp=NULL;
linklist *p=NULL;
p=Creat();
ch1='n';
while(tolower(ch1)=='n')
{
printf("请输入产品型号: \n");
scanf("%s",ntype);
printf("请输入这批货的价位: \n");
scanf("%d",&nprise);
printf("请输入这批货的数量: \n");
scanf("%d",&nnum_of_goods);
printf("请确认你的输入[y/n]: ");
ch1=getch();
if(tolower(ch1)=='y')
break;
}
while(strcmp(ntype,"end")!=0)
{
temp=(linklist *)malloc(sizeof(linklist));
strcpy(temp->product_type,ntype);
temp->num_of_goods=nnum_of_goods;
temp->prise=nprise;
Insert(p,temp);
printf("\n 您已经成功登记了该产品 ! \n");
ch2='n';
while(tolower(ch2)=='n')
{
printf("请输入产品型号: \n");
scanf("%s",ntype);
printf("请输入这批货的价位: \n");
scanf("%d",&nprise);
printf("请输入这批货的数量: \n");
scanf("%d",&nnum_of_goods);
printf("请确认你的输入[y/n]: ");
ch2=getch();
if(tolower(ch2)=='y')
break;
}
}
return p;
}
void Outprint(linklist* head)
{
linklist *p=head;
Print(p);
}
void PriseSearch(linklist *head)
{
linklist *p=NULL;
char ntype[LENGTH];
printf("请输入待查询产品型号: \n");
scanf("%s",ntype);
p=Search(head,ntype);
if(!p);
else
{
printf("%s",p->product_type);
printf("的价格是: ");
printf("%4d",p->prise);
}
}
void Addgoods(linklist* head)
{
linklist *obj;
int num;
char ch;
char ntype[LENGTH];
printf("请输入产品型号: \n");
scanf("%s",ntype);
printf("请输入产品数量: \n");
scanf("%d",&num);
printf("请确认以上输入[y/Y]:");
ch=getch();
if(tolower(ch)=='y')
{
obj=Search(head,ntype);
if(!obj)printf("\n 操作失败! \n");
else
{
obj->num_of_goods+=num;
printf("\n 修改成功! \n");
}
}
else
printf("\n 添加错误,请重新添加! \n");
}
void Delgoods(linklist* head)
{
linklist *obj;
int num;
char ch;
char ntype[LENGTH];
printf("请输入产品型号: \n");
scanf("%s",ntype);
printf("请输入产品数量: \n");
scanf("%d",&num);
printf("请确认以上输入[y/Y]:");
ch=getch();
if(tolower(ch)=='y')
{
obj=Search(head,ntype);
if(!obj)printf("操作失败! \n");
else
{
obj->num_of_goods-=num;
printf("\n 修改成功! \n");
}
}
else
printf("\n 输入错误,请重新删除! \n");
}
void Addnewgoods(linklist *head)
{
char ntype[LENGTH];
char ch;
int nnum_of_goods;
int nprise;
linklist *temp=NULL;
linklist *p=NULL;
ch='n';
while(tolower(ch)=='n')
{
printf("请输入产品型号: \n");
scanf("%s",ntype);
printf("请输入这批货的价位: \n");
scanf("%d",&nprise);
printf("请输入这批货的数量: \n");
scanf("%d",&nnum_of_goods);
printf("请确认你的输入[y/n]: ");
ch=getch();
if(tolower(ch)=='y')
break;
}
temp=(linklist *)malloc(sizeof(linklist));
strcpy(temp->product_type,ntype);
temp->num_of_goods=nnum_of_goods;
temp->prise=nprise;
p=head;
Insert(p,temp);
printf("\n 添加成功! \n");
}
void Deloriginalgoods(linklist * head)
{
char ntype[LENGTH];
linklist *p=NULL;
printf("请输入要删除的货款的品名: \n");
scanf("%s",ntype);
p=Search(head,ntype);
Delete(head, p);
printf("删除成功! \n");
}
int Totalgoods(linklist* head)
{
linklist *q=NULL;
int total=0;
q=head->next;
printf("\n 现存货物: \n");
while(q!=NULL)
{
printf("%s,%4d ",q->product_type ,q->num_of_goods);
total+=q->num_of_goods;
q=q->next;
}
return total;
}
int Totalcosts(linklist* head)
{
linklist *q=NULL;
long int sum=0;
q=head->next;
printf("\n 现存货物: \n");
while(q!=NULL)
{
printf("%s,%8d ",q->product_type,q->prise);
sum+=q->num_of_goods*q->prise;
q=q->next;
}
return sum;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -