键盘输入造链表1

#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;
}

转载于:https://www.cnblogs.com/wangyuqi/p/5567773.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值