线性表1、某软件公司大约有30名员工,每名员工有姓名、工号、职务等属性,每年都有员工离职和入职。把所有员工按照顺序存储结构建立一个线性表,建立离职和入职函数,当有员工离职或入职时,修改线性表,并且打印最新的员工名单。#includestdafx.h#includestdio.h#includestdlib.h#includemalloc.h#defineSIZEsizeof(employee)typedefstructemployee{charname[20];intnumber;charpost[20];employee*next;}employee;intn;employee*s;voidInitComp(){printf(startcreate:\n);inti=0;employee*p,*q=NULL;while(in){p=(employee*)malloc(SIZE);printf(pleaseentername\n);scanf_s(%s,&(p-name),20);printf(pleaseenternumber\n);scanf_s(%d,&(p-number));printf(pleaseenterpost\n);scanf_s(%s,&(p-post),20);p-next=NULL;i++;if(i==1){s=p;q=p;}else{q-next=p;q=q-next;}}}voidEmpInsert(){employee*p,*q=s;while(q-next!=NULL)q=q-next;p=(employee*)malloc(SIZE);printf(pleaseentername\n);scanf_s(%s,&p-name,20);printf(pleaseenternumber\n);scanf_s(%d,&p-number);printf(pleaseenterpost\n);scanf_s(%s,&p-post,20);q-next=p;p-next=NULL;n++;}voidEmpDelete(intnum){employee*p=s,*q=s;inti=0,j=0;while(jn){i=p-number;if(i==num){if(p==s){s=s-next;}else{q-next=p-next;}n--;return;}else{q=p;p=p-next;j++;}}printf(numbernotfound\n);}voidEmpPrint(){employee*p=s;printf(thelistofemployees\n);while(p!=NULL){printf(%s\t%d\t%s\n,p-name,p-number,p-post);p=p-next;}}int_tmain(intargc,_TCHAR*argv[]){intl,m;printf(createlist,pleaseenterthenumberoftheemployee\n);scanf_s(%d,&n);InitComp();EmpPrint();while(1){printf(enternumbertochooseaction:1forindert,2fordelete\n);scanf_s(%d,&l);switch(l){case1:EmpInsert();EmpPrint();break;case2:printf(pleaseenterthenumberoftheemployeeyoudelete\n);scanf_s(%d,&m);EmpDelete(m);EmpPrint();break;default:EmpPrint();}}system(pause);return0;}2、约瑟夫(Josephus)环问题:编号为1,2,3,…,n的n个人按顺时针方向围坐一圈,每人持有一个密码(正整数)。一开始任选一个正整数作为报数的上限值m,从第一个人开始按顺时针方向自1开始顺序报数,报到m时停止。报m的人出列,将他的密码作为新的m值,从他在顺时针方向上的下一人开始重新从1报数,如此下去,直到所有人全部出列为止。建立n个人的单循环链表存储结构,运行结束后,输出依次出队的人的序号。#includestdafx.h#includestdio.h#includestdlib.hstructperson{intnum;intcode;person*next;};person*h;voidCreaCircle(){intn,i;person*p,*q=NULL,*r=NULL;printf(pleaseenterthrnemberofpeople:\n);scanf_s(%d,&n);for(i=1;in+1;i++){p=(person*)malloc(sizeof(person));p-num=i;printf(pleaseenterthecodeofthe%dperson:\n,i);scanf_s(%d,&p-code);p-next=NULL;if(i==1){h=p;q=p;}q-next=p;q=p;}q-next=h;}voidRunGame(){intm,i;person*r,*t=h;printf(pleaseenterthefirstcode:\n);scanf_s(%d,&m);while(t-next!=t){for(i=1;im-1;i++)t=t-next;r=t-next;m=r-code;t-next=r-next;printf(the%dpersoniskicked\n,r-num);}}intmain(){CreaCircle();RunGame();system(pause);return0;}栈和队列3、某商场有一个100个车位的停车场,当车位未满时,等待的车辆可以进入并计时;当车位已满时,必须有车辆离开,等待的车辆才能进入;当车辆离开时计算停留的的时间,并且按照每小时1元收费。汽车的输入信息格式可以是(进入/离开,车牌号,进入/离开时间),要求可以随时显示停车场内的车辆信息以及收费历史记录。#includeiostream#includetime.h#includestdlib.h#includewindows.h#includestdio.husingnamespacestd;#defineLIST_INIT_SIZE10#definePRICE1typedefstructCar{intcarnumber;intmoney;time_tentertime;time_tleavetime;}Car;typedefstructParkList{Car*head;intlength;intlistsize;}ParkList;typedefstructWaitNode{CarWaitCar;WaitNode*next;}WaitNode,*WaitList;typedefstructLeaveNode{CarLeaveCar;LeaveNode*next;}LeaveNode,*LeaveList;intinit_LeaveList(LeaveList&L){L=(LeaveList)malloc(sizeof(LeaveNode));L-next=NULL;}intinit_WaitList(WaitList&WL,Carwc){WL=(WaitList)malloc(sizeof(WaitNode));WL-WaitCar=wc;WL-next=NULL;}voidPut_LeaveList(LeaveList&L,Carlc){LeaveListp=L;if(p==NULL){return;}while(p-next){p=p-next;}LeaveListq=(LeaveList)malloc(sizeof(LeaveNode));q-LeaveCar=lc;p-next=q;q-next=NULL;q-LeaveCar.money=(q-LeaveCar.leavetime-q-LeaveCar.entertime)*PRICE;}voidPutelem_WaitList(WaitList&WL,Carwc){WaitListp=WL;if(p==NULL){init_WaitList(WL,wc);return;}while(p-next){p=p-next;}WaitListq=(WaitList)malloc(sizeof(WaitNode));q-WaitCar=wc;p-next=q;q-next=NULL;}voiddelete_WaitList(WaitList&WL,Car&c){if(WL==NULL){return;}WaitListp=WL;c=p-WaitCar;if(WL-next==NULL){WL=NULL;}else{WL=WL-next;}free(p);}CarCreateCar(intcarnum){Car*pc=(Car*)malloc(sizeof(Car));pc-carnumber=carnum;pc-entertime=time(NULL);return*pc;}intinit_Parklist(ParkList&p){p.head=(Car*)malloc(LIST_INIT_SIZE*sizeof(Car));if(!p.head)return0;p.length=0;p.listsize=LIST_INIT_SIZE;return1;}intput_ParkList(ParkList&p,WaitList&WL,Carc){if(p.length==p.listsize){if(WL==NULL){init_WaitList(WL,c);}elsePutelem_WaitList(WL,c);return0;}Car*pc=p.head;pc[p.length]=c;p.length+=1;return1;}intinsert_ParkList(ParkList&p,WaitList&WL,inti){Carc;delete_WaitList(WL,c);if(i0||i=p.length){return0;}Car*pc=p.head;for(intj=p.length-1;ji-1;j--){pc[j+1]=pc[j];}pc[i]=c;p.length+=1;return1;}intdelete_ParkList(ParkList&p,LeaveList&L,inti){if(i=0&&ip.length){Car*pc=p.head;pc[i].leavetime=time(NULL);Put_LeaveList(L,pc[i]);for(intj=i;jp.length-1;j++){pc[j]=pc[j+1];}p.length-=1;return1;}elsereturn0;}voidshowParkList(ParkListp){if(p.head!=NULL){Car*pc=p.head;printf(ParkList:\n);for(intj=0;jp.length;j++){printf(%d%s\n,pc[j].carnumber,ctime(&pc[j].entertime));}printf(\n);}}voidshowWaitList(WaitListWL){WaitListp=WL;printf(WaitList:\n);while(p){printf(%d%s\n,p-WaitCar.carnumber,ctime(&(p-WaitCar.entertime)));p=p-next;}}voidshowLe