#include<iostream>
#include<string.h>
//#include<malloc.h>
//#include<stdio.h>
using namespace std;
typedef class txl
{
public:
char name[20];
char number[30];
char xh[20];
txl *next;
}txl;
/**************************************分配空间、初始化**********************************/
void fp (txl *p)
{
txl *s;
int i;
s=(txl *)malloc(sizeof(txl));
p=s;
cout<<"请输入姓名,电话和学号:"<<endl;
for(i=0;i<=0;i++)
{
p=p->next;
p=(txl*)malloc(sizeof(txl));
cout<<"请输入姓名:"<<endl;
cin>>p->name;
cout<<"请输入电话:"<<endl;
cin>>p->number;
cout<<"请输入学号:"<<endl;
cin>>p->xh;
}
if(i==1)
{
cout<<"好了,先输入这六个吧。"<<endl;
}
}
/******************************增添*******************************/
void zt(txl *p)
{
while(p->next==NULL)
{
p=p->next;
p=(txl*)malloc(sizeof(txl));
}
cout<<"请输入姓名:"<<endl;
cin>>p->name;
cout<<"请输入电话:"<<endl;
cin>>p->number;
cout<<"请输入学号:"<<endl;
cin>>p->xh;
}
/*****************************输出信息****************************///未完,待做;
void sc(txl *p)
{
while(p->next!=NULL)
{
p=p->next;
cout<<"姓名为:"<<endl<<(p->name)<<endl;
cout<<"电话为:"<<endl<<(p->number)<<endl;
cout<<"学号为:"<<endl<<(p->xh)<<endl;
}
cout<<"hahahahahahhah";
}
void namecx(txl *p)
{
char a[20];
cout<<"请输入您要查询的名字:"<<endl;
cin>>a;
while(p->next!=0)
{
p=p->next;
if(strcmp(a,p->name)==0)
{
cout<<"此人的姓名为:"<<(p->name)<<endl;
cout<<"此人的电话为:"<<p->number<<endl;
cout<<"此人的学号为:"<<p->xh<<endl;
}
}
}
int main()
{
txl l;
txl *s=&l;
fp(s);
zt(s);
//sc(s);
namecx(s);
return 0;
}