日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

c语言仓库管理系统链表,仓库管理系统 C语言 C++ 数据结构 链表 课程设计

發(fā)布時間:2024/4/13 c/c++ 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言仓库管理系统链表,仓库管理系统 C语言 C++ 数据结构 链表 课程设计 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

倉庫管理系統(tǒng) C語言 C++ 數(shù)據(jù)結(jié)構(gòu) 鏈表 課程設(shè)計

#include

#include

#include

#include

#define MAX 64

typedef struct node{ /* 定義結(jié)構(gòu)體類型dnode */

int number; /* 貨物編號 */

char name[MAX]; /* 貨物名稱 */

int counter; /* 貨物數(shù)量 */

struct node *prior,*next; /* 前驅(qū)和后繼指針 */

}dnode;

dnode* head = NULL;

void output_one(dnode* n)/* 輸出一條記錄 */

{

printf("%d\t%s\t%d\n", n->number, n->name, n->counter);

}

void output()/* 輸出所有記錄 */

{

dnode* pos = head;

if(head == NULL)

{

return;

}

while (pos)

{

output_one(pos);/* 循環(huán)調(diào)用output_one */

pos = pos->next;

}

}

int insert()/* 插入一條數(shù)據(jù) */

{

dnode* pos = head;

dnode* n = malloc(sizeof(dnode));

n->prior = NULL;

n->next = NULL;

printf("請輸入貨物編號:");

scanf("%d", &n->number);

printf("請輸入貨物名稱:");

scanf("%s", n->name);

printf("請輸入貨物數(shù)量:");

scanf("%d", &n->counter);

if(head==NULL)/* 如果還沒有頭節(jié)點,就作為頭節(jié)點 */

{

head = n;

return 1;

}

while (pos)

{

if(pos->number > n->number)/* 按順序查找,如果找到比自己大的,就插在它前面 */

{

if(pos->prior)

pos->prior->next = n;

n->prior = pos->prior;

pos->prior = n;

if(pos->next)

pos->next->prior = n;

n->next = pos;

return 1;

}

else if(pos->number == n->number)

{

free(n);

return 0;/* 有重復(fù)數(shù)據(jù),插入不成功 */

}

if (!pos->next)/* 如果已經(jīng)到鏈表尾部,插入到后面 */

{

pos->next = n;

n->prior = pos;

return 1;

}

pos = pos->next;

}

return 1;

}

void init()

{

while (1)/* 初始化,循環(huán)插入 */

{

insert();

printf("按任意鍵繼續(xù)輸入,按Esc停止輸入\n");

if(getch()==27)

break;

}

}

int delete()/* 刪除一條記錄 */

{

int num;

dnode* pos = head;

printf("請輸入要刪除的編號:");

scanf("%d", &num);

if(head == NULL)

{

return 0;

}

while (pos)

{

if(pos->number == num)/* 找到匹配的項 */

{

if(pos->prior)

pos->prior->next = pos->next;

if(pos->next)

pos->next->prior = pos->prior;

free(pos);

return 1;

}

pos = pos->next;

}

return 0;// 沒找到

}

int amend()/* 修改數(shù)量 */

{

int num, count;

dnode* pos = head;

printf("請輸入要修改的編號:");

scanf("%d", &num);

printf("請輸入要修改的數(shù)量:");

scanf("%d", &count);

if(head == NULL)

{

return 0;

}

while (pos)

{

if(pos->number == num)

{

if (count == 0)/* 如果數(shù)量是0,就刪除 */

{

if(pos->prior)

pos->prior->next = pos->next;

if(pos->next)

pos->next->prior = pos->prior;

free(pos);

return 1;

}

pos->counter = count;

return 1;

}

pos = pos->next;

}

retu

總結(jié)

以上是生活随笔為你收集整理的c语言仓库管理系统链表,仓库管理系统 C语言 C++ 数据结构 链表 课程设计的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。