#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct BOOK
{
int id,usr[10],total,store,days[10];
char name[31],author[21];
}books[100];
/*上面是結構體的定義,用於存放書籍及借書的信息。*/
void page_title(char *menu_item)
{
clrscr();
printf(">>> 圖 書 管 理 系 統 <<<\n\n- %s -\n\n",menu_item);
}
/*上面是列印頁眉的函數,同時通過參數menu_item,可以顯示當前的狀態。*/
void return_confirm(void)
{
printf("\n按任意鍵返回……\n");
getch();
}
/*上面是返回前請求確認的函數,以便在返回前觀察結果*/
int search_book(void)
{
int n,i;
printf("請輸入圖書序號:");
scanf("%d",&i);
for(n=0;n<100;n++)
{
if(books[n].id==i)
{
printf("書名:%s\n",books[n].name);
printf("作者:%s\n",books[n].author);
printf("存數:%d of ",books[n].store);
printf("%d\n",books[n].total);
return n;
}
}
printf("\n輸入錯誤或無效圖書序號.\n");
return -1;
}
/*上面的函數是在數組中找到圖書號匹配的記錄,顯示其信息並返
回數組下標,如果找不到相應記錄則提示錯誤並返回-1。*/
void book_out(void)
{
int n,s,l,d;
page_title("借閱圖書");
if((n=search_book())!=-1&&books[n].store>0)
{
printf("請輸入借書證序號:");
scanf("%d",&s);
printf("請輸入可借天數:");
scanf("%d",&d);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==0)
{
books[n].usr[l]=s;
books[n].days[l]=d;
break;
}
}
books[n].store--;
}
if(n!=-1&&books[n].store==0) printf("此書已經全部借出.\n");
return_confirm();
}
/*上面是借書的函數,首先調用找書函數*/
void book_in(void)
{
int n,s,l;
page_title("歸還圖書");
if((n=search_book())!=-1&&books[n].store<books[n].total)
{
printf("借閱者圖書證列表:\n");
for(l=0;l<10;l++)
if (books[n].usr[l]!=0)
printf("[%d] - %d天\n",books[n].usr[l],books[n].days[l]);
printf("請輸入借書證序號:");
scanf("%d",&s);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==s)
{
books[n].usr[l]=0;
books[n].days[l]=0;
break;
}
}
books[n].store++;
}
if(n!=-1&&books[n].store==books[n].total)
printf("全部入藏.\n");
return_confirm();
}
void book_add(void)
{
int n;
page_title("注冊新書");
for(n=0;n<100;n++)
if(books[n].id==0) break;
printf("序號:");
scanf("%d",&books[n].id);
『貳』 C語言倉庫管理系統
倉庫管理系統C語言C++數據結構鏈表課程設計
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>
#define MAX 64
typedef struct node{ /* 定義結構體類型dnode */ int number; /* 貨物編號 */ char name[MAX]; /* 貨物名稱 */ int counter; /* 貨物數量 */ struct node *prior,*next; /* 前驅和後繼指針 */}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); /* 循環調用output_one */ pos = pos->next; }}
int insert() /* 插入一條數據 */{ 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("請輸入貨物數量:"); scanf("%d", &n->counter); if(head==NULL) /* 如果還沒有頭節點,就作為頭節點 */ { 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; /* 有重復數據,插入不成功 */ } if (!pos->next) /* 如果已經到鏈表尾部,插入到後面 */ { pos->next = n; n->prior = pos; return 1; } pos = pos->next;
} return 1;}
void init(){ while (1) /* 初始化,循環插入 */ { insert(); printf("按任意鍵繼續輸入,按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() /* 修改數量 */{ int num, count; dnode* pos = head; printf("請輸入要修改的編號:"); scanf("%d", &num); printf("請輸入要修改的數量:"); scanf("%d", &count); if(head == NULL) { return 0; } while (pos) { if(pos->number == num) { if (count == 0) /* 如果數量是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; } return 0; }
void search() /* 按編號查找 */{ int num; dnode* pos = head;
printf("請輸入要查找的編號:"); scanf("%d", &num);
if(head == NULL) { return; } while (pos) { if(pos->number == num) { output_one(pos); /* 找到就列印 */ return; } pos = pos->next; }}
void search_by_name() /* 按名稱查找 */{ char name[MAX]; dnode* pos = head; printf("請輸入要查找的名稱:"); scanf("%s", name);
if(head == NULL) { return; } while (pos) { if(!strcmp(pos->name, name)) output_one(pos); pos = pos->next; }}
int main(){ init(); while (1) { char ch; system("cls"); printf("\t\t\t\ti 增加新貨物\n"); printf("\t\t\t\td 刪除某種貨物\n"); printf("\t\t\t\ta 修改某種貨物的數量\n"); printf("\t\t\t\ts 查找指定的貨物\n"); printf("\t\t\t\to 輸出存貨信息\n"); printf("\t\t\t\tq 退出程序\n"); ch = getch(); switch (ch) { case 'i': case 'I': insert(); break;
case 'd': case 'D': delete(); break;
case 'a': case 'A': amend(); break;
case 's': case 'S': printf("1. 按編號查找\n2. 按名稱查找\n"); ch = getch(); if(ch == '1') { search(); } else if(ch == '2') { search_by_name(); } break;
case 'o': case 'O': output(); break;
case 'q': case 'Q': return 0; break; } printf("按任意鍵繼續...\n"); getch(); } return 0;}
『叄』 求java編寫的倉庫管理系統源代碼或詳細設計
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
class 商品 extends Panel
{String 代號,名稱;int 庫存;float 單價;
商品(String 代號,String 名稱,int 庫存,float 單價)
{this.代號=代號;this.名稱=名稱;this.庫存=庫存;this.單價=單價;
}
}
class ShowWin extends JFrame implements ActionListener
{ Hashtable hashtable=null;
JTextField 代號文本框=new JTextField(),
名稱文本框=new JTextField(),
庫存文本框=new JTextField(),
單價文本框=new JTextField(),
查詢文本框=new JTextField(),
查詢信息文本框=new JTextField(),
刪除文本框=new JTextField();
JButton b_add=new JButton("添加商品"),
b_del=new JButton("刪除商品"),
b_xun=new JButton("查詢商品"),
b_xiu=new JButton("修改商品"),
b_show=new JButton("顯示商品清單");
JTextArea 顯示區=new JTextArea(25,10);
ShowWin()
{super("倉庫管理窗口");
hashtable=new Hashtable();
Container con=getContentPane();
JScrollPane pane=new JScrollPane(顯示區);
顯示區.setEditable(false);
JPanel save=new JPanel();
save.setLayout(new GridLayout(8,2));
save.add(new Label("輸入代號:"));
save.add(代號文本框);
save.add(new Label("輸入名稱:"));
save.add(名稱文本框);
save.add(new Label("輸入庫存:"));
save.add(庫存文本框);
save.add(new Label("輸入單價:"));
save.add(單價文本框);
save.add(new Label("單擊添加:"));
save.add(b_add);
save.add(new Label("單擊修改:"));
save.add(b_xiu);
save.add(new Label("輸入查詢代號:"));
save.add(查詢文本框);
save.add(new Label("單擊查詢:"));
save.add(b_xun);
JPanel del=new JPanel();
del.setLayout(new GridLayout(2,2));
del.add(new Label("輸入刪除的代號:"));
del.add(刪除文本框);
del.add(new Label("單擊刪除:"));
del.add(b_del);
JPanel show=new JPanel();
show.setLayout(new BorderLayout());
show.add(pane,BorderLayout.CENTER);
show.add(b_show,BorderLayout.SOUTH);
JSplitPane split_one,split_two;
split_one=new JSplitPane(JSplitPane.VERTICAL_SPLIT,save,del);
split_two=new
JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,split_one,show);
con.add(split_two,BorderLayout.CENTER);
JPanel xun=new JPanel();
xun.add(new Label("所得信息:"));
xun.add(查詢信息文本框);
xun.setLayout(new GridLayout(2,1));
con.add(xun,BorderLayout.SOUTH);
b_add.addActionListener(this);
b_del.addActionListener(this);
b_xun.addActionListener(this);
b_xiu.addActionListener(this);
b_show.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==b_add)
{String daihao=null,mingcheng=null;int kucun=0;float danjia=0.0f;
daihao=代號文本框.getText();mingcheng=名稱文本框.getText();
kucun=Integer.parseInt(庫存文本框.getText());
danjia=Float.valueOf(單價文本框.getText()).floatValue();
商品 goods=new 商品(daihao,mingcheng,kucun,danjia);
hashtable.put(daihao,goods);
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out=new ObjectOutputStream(file);
out.writeObject(hashtable); out.close();
}
catch(IOException event){}
}
else if(e.getSource()==b_del)
{String daihao1=刪除文本框.getText();
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in=new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); //////
in.close();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 temp=(商品)hashtable.get(daihao1);
{hashtable.remove(daihao1);}
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out =new ObjectOutputStream(file);
out.writeObject(hashtable);//
out.close();
}
catch(IOException event){}
}
//
else if(e.getSource()==b_xun)
{ String aa;
aa=查詢文本框.getText();
查詢信息文本框.setText(null);
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in =new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); ////
in.close();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 a=(商品)hashtable.get(aa);
查詢信息文本框.setText(" 代號:"+a.代號+" 名稱:"+a.名稱+" 庫存:"+a.庫存+" 單價:"+a.單價);
}
//
else if(e.getSource()==b_xiu)
{ String bb;
bb=代號文本框.getText();
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in=new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); //////
in.close();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 temp=(商品)hashtable.get(bb);
{hashtable.remove(bb);}
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out =new ObjectOutputStream(file);
out.writeObject(hashtable);//
out.close();
}
catch(IOException event){}
String daihao1=null,mingcheng1=null;int kucun1=0;float danjia1=0.0f;
daihao1=代號文本框.getText();mingcheng1=名稱文本框.getText();
kucun1=Integer.parseInt(庫存文本框.getText());
danjia1=Float.valueOf(單價文本框.getText()).floatValue();
商品 goods1=new 商品(daihao1,mingcheng1,kucun1,danjia1);
hashtable.put(daihao1,goods1);
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out=new ObjectOutputStream(file);
out.writeObject(hashtable); out.close();
}
catch(IOException event){}
}
//
else if(e.getSource()==b_show)
{ 顯示區.setText(null);
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in =new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); ////
}
catch(ClassNotFoundException event){}
catch(IOException event){}
Enumeration enum=hashtable.elements();
while(enum.hasMoreElements())
{ 商品 te=(商品)enum.nextElement();
顯示區.append("商品代號:"+te.代號+" ");
顯示區.append("商品名稱:"+te.名稱+" ");
顯示區.append("商品庫存:"+te.庫存+" ");
顯示區.append("商品單價:"+te.單價+" ");
顯示區.append("\n ");
}
}
}
}
public class LinkListFour
{public static void main(String args[])
{ ShowWin win=new ShowWin();
win.setSize(400,350);
win.setVisible(true);
win.addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{ System.exit(0);}});
}
}
『肆』 C語言寫一個倉庫管理系統
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<malloc.h>#define max 32int ifempty=0;//標志,判斷鏈表是無否為空typedef struct dnode /* 定義雙向鏈表結構體 */ {int number; /* 貨物編號 */char name[max]; /* 貨物名稱 */ int counter; /* 貨物數量 */struct dnode *prior, *next;/* 定義兩指針,分別指向其前驅和後繼 */}dlnode; dlnode *create(dlnode *L);dlnode *input(dlnode *L);dlnode *output(dlnode *L);dlnode * outnum(dlnode *L);dlnode * outname(dlnode *L);dlnode *current(dlnode *L);void search(dlnode *L);void print(dlnode *L);void searchnum(dlnode *L);void searchname(dlnode *L);void display(dlnode *L) ;void main(){int x;dlnode *L;if(!(L=(dlnode *)malloc(sizeof(dlnode)))) //分配空間{printf("\n");exit(1);}create(L);///調用函數,創建頭節點while(1){////////////////////////主菜單///////////////////////////printf(" ============================\n");printf(" 1. 貨物出庫和入庫\n");printf(" 2. 查找貨物表\n"); printf(" 3. 顯示倉庫貨物表\n");printf(" 4. 輸出到文件\n");printf(" 0. 退出\n");printf(" =============================\n");printf(" 選擇0--3:");scanf("%d",&x);switch(x){case 2:search(L);break;//調用查找函數case 1:current(L);break;//調用入庫出庫函數case 3:display(L);break;//調用顯示輸出函數case 4:print(L);break;//調用列印函數case 0:printf("\n bye!see you!\n");getchar();getchar();exit(0);//退出程序default:printf("\n Enter erreor!please input 0--4!"); getchar();getchar();}}}dlnode *create(dlnode *L)//創建鏈表頭節點{printf(" 歡迎使用我的倉庫管理系統");getchar(); ifempty=0;///////初始化頭節點的值////////L->next=NULL;L->prior=NULL;L->number=L->counter=0;strcpy(L->name," "); return L;}void search(dlnode *L) ///查找的主要菜單{int y;if(ifempty==0){printf("沒有輸入貨物!\n");getchar();getchar();return;}else{while(1){printf("=====================\n");printf("1.按編號查詢\n");printf("2.按貨物名稱查詢\n");printf("0.返回上一層\n");printf("====================\n");printf("選擇0--2:");scanf("%d",&y);switch(y){case 1:searchnum(L);break;//調用按編號查找的函數case 2:searchname(L);break;//調用按名稱查找的函數case 0:return;//返回default:printf("enter error!Please input 0--2!\n\n");getchar();getchar();printf("\n\n");}}}}void searchnum(dlnode *L)///按編號查找的函數{int num,flag=0;//flag為是否找到的標志dlnode *head=L;if(ifempty==0){printf("沒有貨物被輸入\n");getchar();getchar();return;}printf("輸入你要查找的貨物編號:\n");scanf("%d",&num);while((L=L->next)!=head){if(L->number==num){ flag=1;//flag為1時表示找到printf("找到指定編號貨物 \n"); printf("\n編號:%d\n",L->number);printf("名稱:%s\n",L->name) ;printf("數量:%d\n\n",L->counter); } }if(flag==0)//flag為0時表示沒有找到printf("沒有找到指定編號貨物,請查看是否還有貨物。\n");getchar();getchar();}void searchname(dlnode *L)//按名稱查找的函數{int flag=0;//flag為是否找到的標志char na[32];dlnode *head=L;if(ifempty==0){printf("沒有貨物被輸入\n");getchar();getchar();return;}printf("輸入你要查找的貨物名稱\n");scanf("%s",&na);while((L=L->next)!=head){if(strcmp(L->name,na)==0){ flag=1;//flag為1時表示找到printf("找到指定名稱貨物 \n"); printf("\n編號:%d\n",L->number);printf("名稱:%s\n",L->name) ;printf("數量:%d\n\n",L->counter); } }if(flag==0)//flag為0時表示沒有找到printf("沒有找到指定編號貨物,請查看是否還有貨物。\n\n");getchar();getchar();}dlnode *current(dlnode *L)//貨物出庫入庫函數{int y;while(1){printf("========================\n");printf(" 1.貨物入庫\n");printf(" 2.貨物出庫\n");printf(" 0.返回上一層\n");printf("========================\n");printf(" 選擇0--2:");scanf("%d",&y);switch(y){case 1:input(L);break;//調用入庫函數case 2:output(L);break;//調用出庫函數case 0:return(L);//返回上一層default:printf("enter error!Please input 0--2!");getchar();getchar();printf("\n\n");}}}dlnode *input(dlnode *L)//定義入庫函數{dlnode *in,*head;head=in=(dlnode *)malloc(sizeof(dlnode));//分配空間head=L;printf("\n請輸入貨物數據:\n");printf("編號:");scanf("%d",&in->number);printf("名稱:");scanf("%s",&in->name);printf("數量:");scanf("%d",&in->counter);if(L->next==NULL) //如果只有頭節點,{ //把剛輸入的in節點L->next=in; //跟在頭節點後面L->prior=in; //in->next=L; //in->prior=L; //ifempty++; //ifempty加1}else{//如果當前L的下一個節點不是頭節點while((L=L->next)!=head){//如果輸入的數大於L->number,則插到L的前面if(L->number<in->number){in->next=L;in->prior=L->prior; L->prior->next=in;L->prior=in;ifempty++; //ifempty加1return(head);} }//輸入的編號比其它編號都小,則插到最後個節點,並首尾相連head->prior->next=in;in->prior=head->prior;head->prior=in;in->next=head;ifempty++; //ifempty加1} return head;}dlnode *output(dlnode *L)//出庫的函數{int y;dlnode *head=L;if(ifempty==0)//檢測是否有貨物輸入{printf("沒有貨物輸入系統\n");getchar();getchar();return(head);} while(1){printf("=============\n");printf("1.按編號出庫\n");printf("2.按名稱出庫\n");printf("0.返回上一層\n");printf("==============\n");printf("選擇0--2:");scanf("%d",&y);switch(y){case 1:outnum(L);break;//調用按編號出庫函數case 2:outname(L);break;//調用按名稱出庫函數case 0:return(L);default:printf("enter error!Please input 0--2!");getchar();getchar();printf("\n\n");}}} dlnode *outnum(dlnode *L)//按編號出庫函數{ int num;dlnode *head=L;printf("請輸入出庫貨物的編號:");scanf("%d",&num);while((L=L->next)!=head){//如果找到就刪除節點if(L->number==num){L->prior->next=L->next;L->next->prior=L->prior;ifempty--; //ifempty減1 printf("編號為%d的貨物成功出庫",num); getchar();getchar();return head; } }printf("沒有此編號的貨物,請查看是否還有貨物。\n\n");getchar();getchar();return (head);}dlnode *outname(dlnode *L)//按名稱出庫函數{char na[32];dlnode *head=L;printf("請輸入出庫貨物的名稱:");scanf("%s",&na);while((L=L->next)!=head){//如果找到就刪除節點if(strcmp(L->name,na)==0){L->prior->next=L->next;L->next->prior=L->prior;ifempty--; //ifempty減1 printf("名稱為%s的貨物成功出庫",na);getchar();getchar();return (head);}}printf("沒有此名稱的貨物,請查看是否還有貨物。\n\n");getchar();getchar();return(head);} void display(dlnode *L)//顯示貨物清單{dlnode *head=L;if(ifempty==0){printf("沒有貨物可顯示\n");getchar();getchar();return;}L=L->next;do{ printf("\n編號:%d\n",L->number);printf("名稱:%s\n",L->name) ;printf("數量:%d\n\n",L->counter);}while((L=L->next)!=head);getchar();getchar(); }void print(dlnode *L){dlnode *head=L;L=L->next;char filename[max];FILE *out;if(ifempty==0){printf("沒有貨物可輸出\n");getchar();getchar();return;}printf("請輸入文件名稱:");scanf("%s",filename);if((out=fopen(filename,"w"))==NULL){printf("打開文件失敗!\n");getchar();getchar();return;}do{ fprintf(out,"編號:%d\n名稱:%s\n數量:%d\n\n",L->number,L->name,L->counter);}while((L=L->next)!=head);printf("輸出成功\n");getchar();getchar();fclose(out);}
『伍』 倉庫管理系統源代碼
你要什麼語言的?我有vb的