1 源程序: # include //包含文件读写 # include # include //包含strcmp()字符是否相等 #include //包含system("cls")清屏 #define MAX 60 //下列字符数组的大小 struct Date{//日期 char year[MAX];//年 char month[MAX];//月 char day[MAX];//日 }; struct Goods{//药品信息 char name[MAX];//药品名称 char price[MAX];//药品价格 char number[MAX];//药品数量 char cost[MAX];//药品总价 char kind[MAX];//药品的种类 Date indate;//入库日期 Date xiaoqi;//到期时间 Goods * next;//下一个结点 }; class Cangkuguanli { //类定义与实现 private: int length;//客户数量 Goods * head;//列表的头结点 Goods * current;//当前结点 public: Cangkuguanli()//构造函数 { head=new Goods;//创建头结点 current=head; current->next=NULL; length=0;//长度为 0 } void Creatlist()//创建新的列表 { char g='Y'; int s=0; length=0;//初始长度为 0; current=head; do { 2 Goods * temp=new Goods ;//构建新结点信息 length++; //每加一个结点 链表长度增 1 temp->next=NULL; couttemp->name; cout