-
大小: 2KB文件類型: .cpp金幣: 1下載: 1 次發(fā)布日期: 2021-05-28
- 語言: C/C++
- 標簽:
資源簡介
某軟件公司大約有30名員工,每名員工有姓名、工號、職務等屬性,每年都有員工離職和入職。
把所有員工按照順序存儲結構建立一個線性表,建立離職和入職函數(shù),當有員工離職或入職時,修改線性表,并且打印最新的員工名單。
代碼片段和文件信息
//?WQL01.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“stdio.h“
#include?
#define??LIST_INIT_SIZE?1000?//初始分配
#define??LISTINCRMENT?10?//分配增加量
#define?LEN?sizeof(LNode)
typedef?struct?LNode{
char?name[8];
int?num;
char?post[8];
struct?LNode?*next;
}LNode;
int?n;//職員總數(shù)
LNode?*L;
LNode?*p1?*?q?=?L;
void?InitList()//創(chuàng)建線性表
{
printf(“輸入記錄:“);
int?i?=?0;
L=NULL;
while(i {
p1=(?LNode?*)malloc(LEN);
fflush(stdin);
printf(“name:“);
scanf(“%s“&p1->name);
printf(“num:“);
fflush(stdin);
scanf(“%d“&p1->num);
printf(“post:“);
fflush(stdin);
scanf(“%s“&p1->post);
p1?->next?=?NULL;
++i;
if(i?>?1)
{
q?->next?=?p1;
q?=?q?->next;
}
if(i==1)
{
L=p1;
q?=?L;
}
}
}
void?ListDel(int?num){
LNode?*p*q;
p=L;
int?ek=n;
while(k>0){
e=p->num;
if(num==e){
if(p==L)
L=p->next;
else{
q=p->next;
q->next=p->next;
free(q);
}
--n;
ret
評論
共有 條評論