【c语言】-药店管理系统
一、前言
此藥店管理系統運用了循環、指針、結構體、鏈表、函數、文件等知識,包含了c語言絕大多數內容。
二、基本思路
藥店管理系統由登錄界面、管理端、用戶端構成。
登錄界面用戶必須先進行注冊,并確認注冊身份。注冊的賬號、密碼、身份信息保存在id文件中。之后進行登錄。如果用戶輸入的信息與id文件中的信息一致,才會登錄成功。
管理端有藥品錄入、顯示、查找和修改功能,用戶端有藥品顯示,查找,購買功能。
藥品的錄入、查找運用了鏈表的建立、增刪、遍歷,顯示運用了單鏈表的冒泡排序。藥品的信息儲存在medicine的文件中,需要的時候讀到鏈表中。
三、分布實現
登錄界面
- 功能實現
運用printf將注冊登錄頁面打印出來。用戶選擇后調到對應函數中。注冊先選擇注冊的身份,隨后輸入賬號密碼,不一致則重新輸入,一致則注冊成功并返回登錄界面。
登錄密碼錯誤上限三次,登錄成功后進入正式頁面。
(2)代碼實現
注冊與登錄界面
int main(int argc, char *argv[]) {//登錄面板 int n;printf("\n\n\n");printf("-----------------------------------------\n");printf("|\t 歡迎使用藥店管理系統\t\t|\n");printf("|\t\t1- 注冊 \t\t|\n");printf("|\t\t2- 登錄 \t\t|\n");printf("|\t\t0- 結束 \t\t|\n");printf("-----------------------------------------\n"); a: printf("請輸入對應數字進行操作:");scanf("%d",&n);if(n==1){system("cls");register_();}else if(n==2){system("cls");login();}else if(n==0){return 0; }else{printf("輸入錯誤,請重新輸入!\n");goto a;}return 0; }注冊函數
a: printf("請確認你要注冊的身份:\n");printf("1-管理員\t\t2-用戶\n");int identity,i;char account[20]={0},password_1[10]={0},password_2[10]={0};scanf("%d",&identity);if(identity==1||identity==2){printf("請輸入賬號:\n");scanf("%s",account); b: printf("請輸入密碼(8位):\n");for(i=0;i<8;i++){password_1[i]=getch();printf("*");}printf("請再次確認密碼:\n");for(i=0;i<8;i++){password_2[i]=getch();printf("*");}printf("%s\n%s",password_1,password_2);if(strcmp(password_1,password_2)==0){printf("注冊成功!\n");}else{printf("密碼輸入不一致!\n");goto b;}}else{printf("輸入錯誤,請重新輸入!\n");goto a;}保存到文件中
FILE *fp;fp=fopen("D:/c/Dev-Cpp/id.txt","a+");if(fp==NULL){printf("文件打開失敗!\n");return 0;}fprintf(fp,"%d %s %s\n",identity,&account,&password_1);fclose(fp);printf("按任意鍵返回!\n");getch();system("cls");main();登錄函數
#include <stdio.h> #include <stdlib.h> #include <windows.h> int login() {int identity=0,j=3;char account_1[20]={0},account_2[20]={0},password_1[10]={0},password_2[10]={0}; a: printf("請輸入賬號:\n");scanf("%s",account_1);printf("請輸入密碼(8位):\n");int judge=0,i;for(i=0;i<8;i++){password_1[i]=getch();printf("*");}FILE *fp;fp=fopen("D:/c/Dev-Cpp/id.txt","a+");if(fp==NULL){printf("賬號不存在,請注冊賬號!\n");system("cls");main();}while(!feof(fp)){fscanf(fp,"%d %s %s\n",&identity,&account_2,&password_2);if(identity==1&&strcmp(account_2,account_1)==0&&strcmp(password_2,password_1)==0){judge=1;break;}else if(identity==2&&strcmp(account_2,account_1)==0&&strcmp(password_2,password_1)==0){judge=2;break;}}fclose(fp);printf("%d",judge);if(judge==0){if(j==0){printf("次數用盡\n");return 0; }system("cls");printf("賬號或密碼錯誤!請重新輸入!(你還有%d次機會)\n",j--);goto a;}else if(judge==1){printf("登錄成功!\n");system("cls");printf("你好,管理員\n");master();}else{printf("登錄成功!\n");system("cls");printf("你好,用戶!\n");customer();} }(3)輸出界面
首界面
注冊界面
登錄界面
管理端
- 藥品錄入
功能實現
首先以單鏈表的形式讀入所錄入藥品名稱與價格,然后以追加方式打開medicine文件將鏈表內信息存入。
代碼實現
藥品錄入
do{scanf("%s %lf",name,&price);s=(Node*)malloc(sizeof(Node));strcpy(s->name,name);s->price=price;r->next=s;r=s;printf("\n繼續錄入?(Y/N)\n");choice=getch();}while(choice=='Y'||choice=='y');r->next=NULL; }文件保存
//文件保存FILE *fp;fp=fopen("medicine","a+");if(fp==NULL){printf("文件打開失敗!\n");return 0;}Node *p;int i;double l;char a[20];for(p=link->next;p;p=p->next){fprintf(fp,"%s %.2lf\n",p->name,p->price);}fclose(fp);輸出界面
(2)藥品顯示
功能實現
將medicine文件中的藥品信息讀到鏈表中進行操作。用戶可以選擇默認的輸出順序,也可以選擇則按照價格的高低順序來輸出。
默認順序即按照錄入順序進行輸出,輸出時會加上序號。
按照價格高低輸出用到單鏈表的排序。我選擇冒泡排序。首先根據藥品標記的序號得出要排序的藥品數目n。然后以while循環n次,在while循環中,首先初始化指針指向第一個藥品信息,然后遍歷鏈表,如果發現此結點的藥品價格比下一個結點的藥品價格高,則交換藥品信息。隨后輸出修改后的鏈表即可。
代碼實現
從文件墮入鏈表
//文件讀取 int i=1;FILE *fp;fp=fopen("medicine","r");if(fp==NULL){printf("文件打開失敗!\n");return 0;}//讀入到鏈表 Node *s,*r,*head;r=(Node*)malloc(sizeof(Node));r->next=NULL;head=r;while(!feof(fp)){s=(Node*)malloc(sizeof(Node));fscanf(fp,"%s %lf",s->name,&s->price);s->order=i++;r->next=s;r=s;}r->next=NULL;fclose(fp);排序部分
while(i-1!=0) {q=head->next;while(q->next->next){if(q->price>q->next->price){s=q->next;char a[20];double m=s->price;s->price=q->price;q->price=m;strcpy(a,s->name);strcpy(s->name,q->name);strcpy(q->name,a);}q=q->next;}i--;}輸出部分
Node *p;p=head->next;while(p->next){printf("%-3d %-20s %-10.2lf\n",p->order,p->name,p->price);p=p->next;}輸出界面
(3)藥品查找
功能實現
查找界面在輸入藥品名稱后,會在文件中尋找對應藥品,如果找到則會輸出并繼續尋找,直到遍歷結束。非法輸入則顯示藥品不存在。
代碼實現
在文件中查找藥品信息
while(!feof(fp)){fscanf(fp,"%s %lf",a,&j);if(!strcmp(a,A)){if(t==0){printf("為你找到以下信息:\n");}printf("%-20s %-10.2lf\n",a,j);t=1;}}fclose(fp);輸出界面
(4)藥品修改
功能實現
將文件中的信息存到鏈表中。用戶可以選擇修改或刪除。用戶輸入要修改的藥品后,遍歷鏈表找到對應信息,然后對鏈表進行基本的修改和刪除。隨后再保存回文件中。
代碼實現
修改信息
do{t=0;printf("請輸入修改藥品名稱:\n");scanf("%s",a);Node *p=head; while(p->next){if(!strcmp(a,p->name)){printf("你要修改的信息為:\n");printf("%-20s %-10.2lf\n",a,j);printf("請重新輸入藥品信息:\n");scanf("%s %.2lf",a,&j);p->order=i;strcpy(p->name,a);p->price=j;t=1;}p=p->next;}if(t==0){printf("所修改的藥品信息不存在!\n");}printf("繼續修改?(Y/N)");choice=getch();}while(choice=='Y'||choice=='y');刪除信息
while(p->next){if(!strcmp(a,p->next->name)){printf("你要刪除的信息為:\n");printf("%-20s %-10.2lf\n",p->next->name,p->next->price);printf("請確認是否刪除(Y/N)");char choice=getch();Node *q=p->next;if(choice=='Y'||choice=='y'){p->next=q->next;free(q);}else{goto d;}t=1;break;}p=p->next;}if(t==0){printf("輸入有誤\n");} d: printf("繼續修改?(Y/N)");choice=getch();}while(choice=='Y'||choice=='y');輸出界面
修改信息
刪除信息
用戶端
(1)藥品購買
功能實現
用戶在選擇購買藥品時,會顯示出從低到高的所有藥品信息和序號。用戶選擇購買的藥品編碼和數目后會打印出對應賬單。
代碼實現
選購階段
printf("請輸入想要購買的藥品編號:\n");scanf("%d",&x);printf("請輸入想要購買的藥品數目:\n");scanf("%d",&number[i]);Node *p=head->next;while(p->next){if(x==p->order){break;}p=p->next;}strcpy(bill[i],p->name);count+=number[i]*p->price;i++;printf("是否要繼續購買(Y/N)\n");w=getch();}while(w=='Y'||w=='y');賬單打印
printf("你的賬單:\n");printf("--------------------------------\n");printf("藥品:\n");for(j=0;j<i;j++){printf("%s X %d\n",bill[j],number[j]);}printf("合計:");printf("%lf\n",count);printf("--------------------------------\n");輸出界面
四、特點
1.運用#include<windows.h>中的system(“cls”)清屏操作,讓界面整潔。
2.非法輸入會顯示錯誤、藥品不存在等。
3.密碼隱式輸出,且次數上限。
4.對于藥品名稱重復,再查找和修改時,都會顯示出來。
五、完整代碼
//項目一: #include <stdio.h> #include <stdlib.h> #include <windows.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) {//登錄面板 int n; printf("\n\n\n"); printf("-----------------------------------------\n"); printf("|\t 歡迎使用藥店管理系統\t\t|\n"); printf("|\t\t1- 注冊 \t\t|\n"); printf("|\t\t2- 登錄 \t\t|\n"); printf("|\t\t0- 結束 \t\t|\n"); printf("-----------------------------------------\n"); a:printf("請輸入對應數字進行操作:"); scanf("%d",&n); if(n==1) { system("cls"); register_(); }else if(n==2) { system("cls"); login(); }else if(n==0) { return 0; }else { printf("輸入錯誤,請重新輸入!\n"); goto a; } return 0; } //項目二: #include <stdio.h> #include <windows.h> int register_() { a:printf("請確認你要注冊的身份:\n"); printf("1-管理員\t\t2-用戶\n"); int identity,i; char account[20]={0},password_1[10]={0},password_2[10]={0}; scanf("%d",&identity); if(identity==1||identity==2) { printf("請輸入賬號:\n"); scanf("%s",account); b:printf("請輸入密碼(8位):\n"); for(i=0;i<8;i++) { password_1[i]=getch(); printf("*"); } printf("請再次確認密碼:\n"); for(i=0;i<8;i++) { password_2[i]=getch(); printf("*"); } printf("%s\n%s",password_1,password_2); if(strcmp(password_1,password_2)==0) { printf("注冊成功!\n"); }else { printf("密碼輸入不一致!\n"); goto b; } }else { printf("輸入錯誤,請重新輸入!\n"); goto a; } FILE *fp; fp=fopen("D:/c/Dev-Cpp/id.txt","a+"); if(fp==NULL) { printf("文件打開失敗!\n"); return 0; } fprintf(fp,"%d %s %s\n",identity,&account,&password_1); fclose(fp); printf("按任意鍵返回!\n"); getch(); system("cls"); main(); } //項目三: #include <stdio.h> #include <stdlib.h> #include <windows.h> int login() { int identity=0,j=3; char account_1[20]={0},account_2[20]={0},password_1[10]={0},password_2[10]={0}; a:printf("請輸入賬號:\n"); scanf("%s",account_1); printf("請輸入密碼(8位):\n"); int judge=0,i; for(i=0;i<8;i++) { password_1[i]=getch(); printf("*"); } FILE *fp; fp=fopen("D:/c/Dev-Cpp/id.txt","a+"); if(fp==NULL) { printf("賬號不存在,請注冊賬號!\n"); system("cls"); main(); } while(!feof(fp)) { fscanf(fp,"%d %s %s\n",&identity,&account_2,&password_2); if(identity==1&&strcmp(account_2,account_1)==0&&strcmp(password_2,password_1)==0) { judge=1; break; }else if(identity==2&&strcmp(account_2,account_1)==0&&strcmp(password_2,password_1)==0) { judge=2; break; } } fclose(fp); printf("%d",judge); if(judge==0) { if(j==0) { printf("次數用盡\n"); return 0; } system("cls"); printf("賬號或密碼錯誤!請重新輸入!(你還有%d次機會)\n",j--); goto a; }else if(judge==1) { printf("登錄成功!\n"); system("cls"); printf("你好,管理員\n"); master(); }else { printf("登錄成功!\n"); system("cls"); printf("你好,用戶!\n"); customer(); } } //項目四: #include <stdio.h>//管理端 #include <windows.h> int master() { printf("=========================================\n"); printf("|管理端: \t\t\t\t|\n"); printf("|1-顯示所有藥品\t\t\t\t|\n"); printf("|2-錄入藥品信息\t\t\t\t|\n"); printf("|3-查詢藥品信息\t\t\t\t|\n"); printf("|4-修改藥品信息\t\t\t\t|\n"); printf("|5-返回登錄頁面\t\t\t\t|\n"); printf("|0-退出程序 \t\t\t\t|\n"); printf("=========================================\n"); a:printf("請選擇功能0-5:\n"); int n; while(1) { scanf("%d",&n); switch(n) { case 1: system("cls"); output_1(); break; case 2: system("cls"); create(); break; case 3: system("cls"); search_1(); break; case 4: system("cls"); revamp(); break; case 5: system("cls"); main(); break; case 0: return 0; default: printf("輸入錯誤,請重新輸入!\n"); goto a; } } } //項目五: #include <stdio.h>//用戶端 #include <windows.h> int customer() { printf("=========================================\n"); printf("|用戶端: \t\t\t\t|\n"); printf("|1-顯示所有藥品\t\t\t\t|\n"); printf("|2-查詢藥品信息\t\t\t\t|\n"); printf("|3-購買藥品 \t\t\t\t|\n"); printf("|4-返回登錄頁面\t\t\t\t|\n"); printf("|0-退出程序 \t\t\t\t|\n"); printf("=========================================\n"); a:printf("請選擇功能0-4:\n"); int n; scanf("%d",&n); switch(n) { case 1: system("cls"); output_2(); break; case 2: system("cls"); search_2(); break; case 3: system("cls"); purchase(); break; case 4: system("cls"); main(); break; case 0: return 0; default: printf("輸入錯誤,請重新輸入!\n"); goto a; } } //項目六: #include <stdio.h>//錄入藥品信息 #include <stdlib.h> #include <string.h> #include <windows.h> typedef struct node { int order; char name[20]; double price; struct node *next; }Node; void list(Node *head)//單鏈表錄入藥品信息 { Node *r,*s; r=head; char choice; char name[20]; int order; double price; do { scanf("%s %lf",name,&price); s=(Node*)malloc(sizeof(Node)); strcpy(s->name,name); s->price=price; r->next=s; r=s; printf("\n繼續錄入?(Y/N)\n"); choice=getch(); }while(choice=='Y'||choice=='y'); r->next=NULL; } int create() { printf("藥名:價格:\n"); Node *link; link=(Node*)malloc(sizeof(Node)); link->next=NULL; list(link); //文件保存 FILE *fp; fp=fopen("medicine","a+"); if(fp==NULL) { printf("文件打開失敗!\n"); return 0; } Node *p; int i; double l; char a[20]; for(p=link->next;p;p=p->next) { fprintf(fp,"%s %.2lf\n",p->name,p->price); } fclose(fp); printf("文件保存完畢,按任意鍵返回!\n"); getch(); system("cls"); master(); } //項目七: #include <stdlib.h> #include <stdio.h> #include <windows.h> typedef struct node { int order; char name[20]; double price; struct node *next; }Node; int output_1() { //文件讀取 int i=1; FILE *fp; fp=fopen("medicine","r"); if(fp==NULL) { printf("文件打開失敗!\n"); return 0; } //讀入到鏈表 Node *s,*r,*head; r=(Node*)malloc(sizeof(Node)); r->next=NULL; head=r; while(!feof(fp)) { s=(Node*)malloc(sizeof(Node)); fscanf(fp,"%s %lf",s->name,&s->price); s->order=i++; r->next=s; r=s; } r->next=NULL; fclose(fp); printf("請選擇輸出格式:(1-默認順序/2-價格順序)\n"); //輸出鏈表 int z; scanf("%d",&z); if(z==1) { Node *p; p=head->next; while(p->next) { printf("%-3d %-20s %-10.2lf\n",p->order,p->name,p->price); p=p->next; } }else if(z==2) { Node *q,*s; while(i-1!=0) { q=head->next; while(q->next->next) { if(q->price>q->next->price) { s=q->next; char a[20]; double m=s->price; s->price=q->price; q->price=m; strcpy(a,s->name); strcpy(s->name,q->name); strcpy(q->name,a); } q=q->next; } i--; } q=head->next; while(q->next) { printf("%-3d %-20s %-10.2lf\n",q->order,q->name,q->price); q=q->next; } }else { printf("輸入有誤,請重新輸入\n"); } printf("按任意鍵返回!\n"); getch(); system("cls"); master(); } //項目八: #include <stdlib.h> #include <stdio.h> #include <windows.h> typedef struct node { int order; char name[20]; double price; struct node *next; }Node; int output_2() { //文件讀取 int i=1; FILE *fp; fp=fopen("medicine","r"); if(fp==NULL) { printf("文件打開失敗!\n"); return 0; } //讀入到鏈表 Node *s,*r,*head; r=(Node*)malloc(sizeof(Node)); r->next=NULL; head=r; while(!feof(fp)) { s=(Node*)malloc(sizeof(Node)); fscanf(fp,"%s %lf",s->name,&s->price); s->order=i++; r->next=s; r=s; } r->next=NULL; fclose(fp); printf("請選擇輸出格式:(1-默認順序/2-價格順序)\n"); //輸出鏈表 int z; scanf("%d",&z); if(z==1) { Node *p; p=head->next; while(p->next) { printf("%-3d %-20s %-10.2lf\n",p->order,p->name,p->price); p=p->next; } }else if(z==2) { Node *q,*s; while(i-1!=0) { q=head->next; while(q->next->next) { if(q->price>q->next->price) { s=q->next; char a[20]; double m=s->price; s->price=q->price; q->price=m; strcpy(a,s->name); strcpy(s->name,q->name); strcpy(q->name,a); } q=q->next; } i--; } q=head->next; while(q->next) { printf("%-3d %-20s %-10.2lf\n",q->order,q->name,q->price); q=q->next; } }else { printf("輸入有誤,請重新輸入\n"); } printf("按任意鍵返回!\n"); getch(); system("cls"); customer(); } //項目九: #include <stdio.h> #include <string.h> #include <windows.h> void search_1() { char A[20]={0},choice; int I=-1,i; double J=-1,j; char a[20]; int x; int t=0; FILE *fp; do { t=0; printf("請輸入藥品名稱:\n"); scanf("%s",A); fp=fopen("medicine","r"); while(!feof(fp)) { fscanf(fp,"%s %lf",a,&j); if(!strcmp(a,A)) { printf("為你找到以下信息:\n"); printf("%-20s %-10.2lf\n",a,j); t=1; break; } } fclose(fp); if(t==0) { printf("輸入藥品不存在!\n"); } printf("繼續查詢?(Y/N)\n"); choice=getch(); }while(choice=='Y'||choice=='y'); printf("按任意鍵返回!\n"); getch(); system("cls"); master(); } //項目十: #include <stdio.h> #include <string.h> #include <windows.h> void search_2() { char A[20]={0},choice; int I=-1,i; double J=-1,j; char a[20]; int x; int t=0; FILE *fp; do { t=0; printf("請輸入藥品名稱:\n"); scanf("%s",A); fp=fopen("medicine","r"); while(!feof(fp)) { fscanf(fp,"%d %s %lf",&i,a,&j); if(!strcmp(a,A)) { printf("為你找到以下信息:\n"); printf("%-3d %-20s %-10.2lf\n",i,a,j); t=1; break; } } fclose(fp); if(t==0) { printf("輸入藥品不存在!\n"); } printf("繼續查詢?(Y/N)\n"); choice=getch(); }while(choice=='Y'||choice=='y'); printf("按任意鍵返回!\n"); getch(); system("cls"); customer(); } //項目十一: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> typedef struct node { int order; char name[20]; double price; struct node *next; }Node; int revamp() { int x,t; int I=-1,i; double J=-1,j; char A[20]={0}; char a[20]; char choice; FILE *fp; //文件讀取 fp=fopen("medicine","r"); if(fp==NULL) { printf("文件打開失敗!"); return 0; } Node *s,*r,*head; r=(Node*)malloc(sizeof(Node)); r->next=NULL; head=r; while(!feof(fp)) { s=(Node*)malloc(sizeof(Node)); fscanf(fp,"%s %lf",s->name,&s->price); r->next=s; r=s; } r->next=NULL; fclose(fp); //操作信息 b:printf("請選擇操作方法(1-修改信息/2-刪除信息):\n"); scanf("%d",&x); if(x==1) { //修改操作 a:do { t=0; printf("請輸入修改藥品名稱:\n"); scanf("%s",a); Node *p=head; while(p->next) { if(!strcmp(a,p->name)) { printf("你要修改的信息為:\n"); printf("%-20s %-10.2lf\n",a,j); printf("請重新輸入藥品信息:\n"); scanf("%s %.2lf",a,&j); p->order=i; strcpy(p->name,a); p->price=j; t=1; break; } p=p->next; } if(t==0) { printf("所修改的藥品信息不存在!\n"); } printf("繼續修改?(Y/N)"); choice=getch(); }while(choice=='Y'||choice=='y'); //刪除操作 }else if(x==2) { do { t=0; printf("請輸入刪除藥品名稱:\n"); scanf("%s",a); Node *p=head; while(p->next) { if(!strcmp(a,p->next->name)) { printf("你要刪除的信息為:\n"); printf("%-20s %-10.2lf\n",p->next->name,p->next->price); printf("請確認是否刪除(Y/N)"); char choice=getch(); Node *q=p->next; if(choice=='Y'||choice=='y') { p->next=q->next; free(q); }else { goto d; } t=1; break; } p=p->next; } if(t==0) { printf("輸入有誤\n"); } d:printf("繼續修改?(Y/N)"); choice=getch(); }while(choice=='Y'||choice=='y'); }else { printf("輸入有誤,請重新輸入\n"); goto b; } //文件保存 FILE *fq; fq=fopen("medicine","w"); if(fp==NULL) { printf("文件打開失敗!\n"); return 0; } Node *q; for(q=head->next;q->next;q=q->next) { fprintf(fq,"%s %.2lf\n",q->name,q->price); } fclose(fq); printf("修改完成!\n"); printf("按任意鍵返回!\n"); getch(); system("cls"); master(); } //項目十二: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> typedef struct node { int order; char name[20]; double price; struct node *next; }Node; int purchase() { //從文件轉到鏈表中 FILE *fp; int z=0; fp=fopen("medicine","r"); if(fp==NULL) { printf("文件打開失敗!\n"); return 0; } Node *s,*r,*head; r=(Node*)malloc(sizeof(Node)); r->next=NULL; head=r; while(!feof(fp)) { s=(Node*)malloc(sizeof(Node)); fscanf(fp,"%s %lf",s->name,&s->price); s->order=z++; r->next=s; r=s; } r->next=NULL; fclose(fp); //顯示所有藥品 Node *p,*t; while(z-1!=0) { p=head->next; while(p->next->next) { if(p->price>p->next->price) { t=p->next; char a[20]; double m=t->price; t->price=p->price; p->price=m; strcpy(a,t->name); strcpy(t->name,p->name); strcpy(p->name,a); } p=p->next; } z--; } p=head->next; while(p->next) { printf("%-3d %-20s %-10.2lf\n",p->order,p->name,p->price); p=p->next; } //購買藥品 int x,i=0,j; double count=0; char bill[200][200],number[200]; char w; printf("--------------------------------\n"); do { printf("請輸入想要購買的藥品編號:\n"); scanf("%d",&x); printf("請輸入想要購買的藥品數目:\n"); scanf("%d",&number[i]); Node *p=head->next; while(p->next) { if(x==p->order) { break; } p=p->next; } strcpy(bill[i],p->name); count+=number[i]*p->price; i++; printf("是否要繼續購買(Y/N)\n"); w=getch(); }while(w=='Y'||w=='y'); printf("你的賬單:\n"); printf("--------------------------------\n"); printf("藥品:\n"); for(j=0;j<i;j++) { printf("%s X %d\n",bill[j],number[j]); } printf("合計:"); printf("%lf\n",count); printf("--------------------------------\n"); printf("按任意鍵返回!\n"); getch(); system("cls"); customer(); }總結
以上是生活随笔為你收集整理的【c语言】-药店管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 小学学校计算机教室使用计划,小学计算机教
- 下一篇: 手机便签文本翻译功能如何使用?