标签:
#include <stdio.h>
#include <malloc.h>
//键盘输入造链表
struct wyq{
char name[100];
int age;
char address[100];
struct wyq*next;
};
int main()
{
struct wyq*
head;
struct wyq*p;
struct wyq*q;
int i;
head=(struct wyq*)malloc(sizeof(struct wyq));
if(NULL==head){
printf("没有申请成功");
exit(-1);
}
printf("输入链表节点内容:\n");
printf("姓名->");
scanf("%s",head->name);
printf("年龄->");
scanf("%s",head->age);
printf("地址->");
scanf("%s",head->address);
head->next=NULL;
p=head;
q=head;
printf("1;继续;2停止\n");
scanf("%d",&i);
while(i==1) {
p=(struct wyq*)malloc(sizeof(struct wyq));
printf("输入链表节点内容:\n");
printf("姓名->");
scanf("%s",p->name);
printf("年龄->");
scanf("%s",p->age);
printf("地址->");
scanf("%s",p->address);
p->next=NULL;
q->next=p;
q=p;
printf("1;继续;2停止\n");
scanf("%d",&i);
if(i==2){
break;
}
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/wangyuqi/p/5567773.html