ent { char id[10]; char name[10]; char sex[10]; char grade [10]; }; struct LNode { Student stu; Student data; LNode*next; }; class LinkList{ public:
LNode*current,*previous; LNode*head; int length; LinkList(){ head= new LNode();
head->next=NULL; length=0; } bool IsListEmpty(){ return length==0; } void LinkList::InsertList(Student x) { LNode*s=new LNode(); s->stu=x; s->next=head->next; head->next=s; length++; } void LinkList::DeleteList(char ID[]) { previous=head; current=head->next; for(int i=0;i
if(strcmp(current->stu.id,ID)==0){ previous->next=current->next; length=length-1;
return; } previous=current; current=current->next; } cout<<"ID="<next; for(int i=0;i cout<<"ID="<stu.id<<"\tNAME="<stu.n ame<<"\tSEX="<stu.sex<<"\tGRADE="<stu .grade<next; } } }; int main(int argc, char* argv[]) { LinkList k; int x=1; while(x!=0){
printf("请输入以下选项:\n"); printf("1:信息浏览\n"); printf("2:插入信息\n"); printf("3:删除信息\n"); printf("0:退出程序\n");
cin>>x; switch(x){ case 1: k.ShowAll(); break; case 2: Student N; cout<<"ID="<>N.id; cout<<"NAME="<>N.name; cout<<"SEX="<>N.sex; cout<<"GRADE="<>N.grade;
k.InsertList(N); break; case 3: char delID[10]; cout<<"请输入想要删除数据项的 ID 号码"<>delID; k.DeleteList(delID); break; case 0: break; } }; return 0; } 调用系统程序 // 实 验 五 .cpp : Defines the entry point for the console application. // #include "stdafx
.h" #include #include void child_process(char command[])
{ PROCESS_INFORMATION piProcInfo; STARTUPINFO Info; Info.cb=sizeof(STARTUPINFO); Info.lpDesktop=NULL; Info.lpTitle=NULL; Info.cbReserved2=0; BOOL bSuccess=CreateProcess(NULL,command,NULL,NULL,false,NULL ,NULL,NULL,&;Info,&;piProcInfo); if(! bSuccess){ cout<<"命令错误"< printf("2——资源管理器\n"); printf("3——任务管理器\n"); printf("4——控制面板\n"); printf("——————————\n"); cin>>x; switch(x) { case 0: break; case 1: child_process("winmsd"); break; case 2: child_process("explorer"); break; case 3: child_process("taskmgr"); break; case 4: child_proce