在疫情期间,由于学校通知我们课程设计不受物理环境的限制,于是C语言课设如约而至。。。刚刚结束的C语言课程设计的确非常煎熬(还不是c语言没有学好嘛),想必也会有很多人像我一样在网上到处找代码,或是恶补链表文件的知识点,但最后还是在网上苦苦的寻找符合老师要求的代码,话不多说,直接上代码。
#include "singlelist.h"
void medicine_menu()//主菜单
{
printf("\t----- Hello! You have entered the management system of pharmacy -----\n\n");
printf("\t\t\t\t\t\t\t\t\tMENU\n\n");
printf("\t\t\t Enter 1 to add the message of medicine.\n");//添加
printf("\t\t\t Enter 2 to check the message of medicine.\n");//查看
printf("\t\t\t Enter 3 to revise the message of medicine.\n");//修改
printf("\t\t\t Enter 4 to search medicine with its number.\n");//按编号查找
printf("\t\t\t Enter 5 to sort medicine by price.\n");//按价格排序
printf("\t\t\t Enter 6 to delete the message of medicine.\n");//删除信息
printf("\t\t\t Enter 7 to exit this system.\n");//退出
printf("\t---------------------------------------------------------------------\n\n");
printf("\t\t\t Please enter the number (1 ~ 7) :");
}
drug *list;
void input()//用户输入
{
int choice = 0;
medicine date;
drug *pMove = NULL;
scanf("%d",&choice);
switch(choice)
{
case 1://添加信息
printf("\t\t\t\t\t----------[ADD MESSAGES]----------\n");
printf("\t\tPlease enter the number,name,MFD,EXP,price,inventory,brand and function\n");
printf("\t\t");
fflush(stdin);
scanf("%s %s %s %s %lf %s %s %s",
date.number,date.name,date.MFD,date.EXP,&date.price,date.inventory,date.brand,date.function);
insert(list, date);
break;
case 2://查看所有信息
printf("\t\t\t\t\t----------[Check Information]----------\n");
print(list);
break;
case 3://修改信息
printf("\t\t\t\t\t----------[Revise Information]----------\n");
printf("\t\tPlease enter the number needed to be revised:");
scanf("%s",date.number);
if(search(list, date.number) == NULL)
{
printf("Erro\n");
}
else
{
drug *node = search(list, date.number)<