简单的商品库存管理程序 c语言(Simple commodity inventory management program c language).doc
文本预览下载声明
简单的商品库存管理程序 c语言(Simple commodity inventory management program c language)
# includes stdio.h
# includes malloc.h
# define len sizeof (struct goods)
struct goods
{
long number.
char name [20];
int count;
struct goods * next;
};
struct goods * creat (struct goods * head);
struct goods * destory (struct goods * head);
struct goods * sell (long number, int count, struct goods * head);
struct goods * stock (long number, int count, struct goods * head);
void list (struct goods * head);
struct goods * (struct goods * p1, struct goods * head);
void main ()
{
struct goods * head = null;
long number.
int count, choose;
i give
{
printf (1. shu ru sang pin xin xi \ n2. xiao shou \ n3. chao zhao \ n4. you ju sang pin xin xi \ n5. qin chu his, you sang pin \ n6. exit \ n \ n );
printf (input choose: \ n);
scanf (% d choose).
if (choose = = 1) head = creat (head);
else if (choose = = 2)
{
printf (input number and count: \ n);
scanf (% 7d% d number count).
head = sell (number, count, head).
}
else if (choose = = 3)
{
printf (input number and count: \ n);
scanf (% 7d% d number count).
head = stock (number, count, head).
}
else if (choose = = 4) list (head);
else if (choose = = 5) head = destory (head);
} while (i choose! = 6);
}
struct goods * creat (struct goods * head1)
{
struct goods * head = null, * p1 * p2;
int n = 0;
if (head1) destory (head1);
p2 = p1 = (struct goods *) malloc (len);
printf (input number name: \ n);
scanf (% 7d% s p2 - number, p2 - name);
p2 - count = 0;
while (p2 - number)
{
if (n = = 0) head = p1.
else p1 - next = p2.
p1 = p2.
p2 = (struct goods *) malloc (len);
printf (input number name: \ n);
scanf (% 7d% s p2 - number, p2 - name);
p2 - count = 0;
n + +;
}
p1 - next = null;
return head;
}
struct goods * destory (struct goods * head)
{
char word;
struct goods * p1 * p2;
p1 = p2 = head;
i give
{
getchar ();
printf (do you really want to destory the goods system y / n \ n?) ;
scanf (% c, word);
}(单词)!= Y 字!= n);
if(word==y)
{
如果(P1)
做
显示全部