首页 文章 药物管理系统-C语言01

药物管理系统-C语言01

2022-05-22 18:49  浏览数:396  来源:Coat    

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <malloc.h>
#include<string.h>
#include<stdlib.h>
const int MAX = 110;
struct Drug
{
int id, specs, price, num;
char name[MAX], manufacturer[MAX], type[MAX];
struct Drug* next;
};
void Menu01();
void Menu02();
struct Drug* Add(struct Drug* head);
struct Drug* LayOut(struct Drug* head);
struct Drug* Delete(struct Drug* head);
void Warehousing(struct Drug* head);
void ExWarehousing(struct Drug* head);
void Stock(struct Drug* head);
void Save(struct Drug* head);
void TransferIn(struct Drug* head);
int main()
{
struct Drug* list = NULL;
int leap = 1, choice;
while (leap)
{
Menu01();
scanf("%d", &choice);
switch (choice)
{
case 1:LayOut(list); break;
case 2:list = Add(list); break;
case 3:Delete(list); break;
case 4:Warehousing(list); break;
case 5:ExWarehousing(list); break;
case 6:Stock(list); break;
case 7:Save(list); break;
case 8:TransferIn(list); break;
case 9:break;
}
}
Menu02();
return 0;
}
void Menu01()
{
printf("*\n");
printf("*1.*\n");
printf("*2.*\n");
printf("*3.*\n");
printf("*4.*\n");
printf("*5.*\n");
printf("*6.*\n");
printf("*7.*\n");
printf("*8.*\n");
printf("*9.*\n");
printf("*\n");
}
void Menu02()
{
printf("*\n");
}
bool Check(char s1[], char s2[])
{
if (strlen(s1) != strlen(s2))
return false;
int t =strlen(s1);
for (int i = 0; i < t; i++)
{
if (s1[i] != s2[i])
return false;
}
return true;
}
struct Drug* LayOut(struct Drug* head)
{
struct Drug* p=head;
char t[MAX]=" ";
int num = 0;
printf("-\n");
while (p != NULL)
{
if (!Check(t, p->type))
{
strcpy(t, p->type);
num++;
printf("%d,%s", num,t);
}
p = p->next;
}
if (num == 0)
printf("-\n");
return (head);
}
struct Drug* Add(struct Drug* head)
{
struct Drug* p1;
p1 = (struct Drug*)malloc(sizeof(struct Drug));
printf("-\n");
printf("-\n");
scanf("%d", &p1->id);
if (p1->id == -1)
return(head);
scanf("%s%s%s%d%d", p1->type,
p1->name, p1->manufacturer,&p1->specs, &p1->price);
p1->num = 0;
while (p1->id!=-1)
{
if (head == NULL)
{
head = p1;
head->next = NULL;
}
else
{
p1->next = head;
head = p1;
}
p1 = (struct Drug*)malloc(sizeof(struct Drug));
scanf("%d", &p1->id);
if (p1->id == -1)
return (head);
scanf("%s%s%s%d%d", p1->type, p1->name,
p1->manufacturer, &p1->specs, &p1->price);
p1->num = 0;
}
return (head);
}



声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)