赞
踩
- #include "stdafx.h"
- #include "windows.h"
- #include "iostream"
-
- using namespace std;
-
- typedef struct Pnode
- {
- char Pname[21];
- char Pphone[12];
- char Psex[5];
- char Padd[21];
- Pnode *pNext;
- }node,*Node;
-
- int main(int argc,char *argv)
- {
- void Init_(Node S);
- void Delete_(Node S);
- void EnList_(Node S);
- void OutList_(Node S);
- void InsertList_(Node S);
-
- int e;
- Node S=(Node)malloc(sizeof(node));
-
- MessageBox(NULL,TEXT("1:Input 2:Reading 3:Delete 4:Insert 5:Help"),
- TEXT("Prompt"),MB_OK|MB_ICONQUESTION);
-
- Init_(S);
- scanf("%d",&e);
-
- while(1)
- {
- if(e==1)
- {
- EnList_(S);scanf("%d",&e);system("cls");
- }
- else if(e==2)
- {
- OutList_(S);scanf("%d",&e);system("cls");
- }
- else if(e==3)
- {
- Delete_(S);scanf("%d",&e);system("cls");
- }
- else if(e==4)
- {
- InsertList_(S);scanf("%d",&e);system("cls");
- }
- else if(e==5)
- {
- MessageBox(NULL,TEXT("1:Input 2:Reading 3:Delete 4:Insert 5:Help"),
- TEXT("Prompt"),MB_OK|MB_ICONQUESTION);
- scanf("%d",&e);system("cls");
- }
- }
- return 0;
- }
-
- void Init_(Node S)
- {
- S->pNext=NULL;
- }
-
- void EnList_(Node S)
- {
- char c;
- Node q=S;
- while(1)
- {
- Node p=(Node)malloc(sizeof(node));
- puts("Name:");
- scanf("%s",&p->Pname);
- puts("Phone:");
- scanf("%s",&p->Pphone);
- puts("Sex:");
- scanf("%s",&p->Psex);
- puts("Address:");
- scanf("%s",&p->Padd);
- p->pNext=NULL;
- p->pNext=q->pNext;
- q->pNext=p;
- puts("Next?(Y/N):");
- getchar();
- c=getchar();
-
- if(c=='y')system("cls");
- else
- {
- system("cls");
- break;
- }
- }
- }
-
- void OutList_(Node S)
- {
- Node p=S->pNext;
- puts("Name Phone Sex Address");
-
- while(p)
- {
- printf("%s %s %s %s\n",p->Pname,p->Pphone,p->Psex,p->Padd);
- p=p->pNext;
- }
- }
-
- void InsertList_(Node S)
- {
- Node p=S;
- Node q=(Node)malloc(sizeof(node));
-
- puts("You want insert information");
- puts("Name:");
- scanf("%s",&q->Pname);
- puts("Phone:");
- scanf("%s",&q->Pphone);
- puts("Sex:");
- scanf("%s",&q->Psex);
- puts("Address:");
- scanf("%s",&q->Padd);
- q->pNext=NULL;
-
- while(p->pNext)
- p=p->pNext;
- q->pNext=p->pNext;
- p->pNext=q;
- MessageBox(NULL,TEXT("Success!"),TEXT("Debug"),MB_OK|MB_ICONASTERISK);
- }
-
- void Delete_(Node S)
- {
- char ch[12];
- Node p=S;
- Node q;
- puts("You want delete name:");
- getchar();
- gets(ch);
-
- while(p->pNext)
- {
- if(strcmp(p->pNext->Pname,ch)==0)
- {
- q=p->pNext;
- p->pNext=q->pNext;
- MessageBox(NULL,TEXT("Success!"),TEXT("Debug"),MB_OK|MB_ICONASTERISK);
- break;
- }
- p=p->pNext;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。