C链表回顾
来源:互联网 发布:移动定制机网络解锁 编辑:程序博客网 时间:2024/05/19 20:56
#define TYPE struct stu
#define LEN sizeof (struct stu)
struct stu
{
int num;
int age;
struct stu *next;
};
TYPE *creat(int n)
{
struct stu *head,*pf,*pb;
int i;
for(i=0;i<n;i++)
{
pb=(TYPE*) malloc(LEN);
printf("input Number and Age\n");
scanf("%d%d",&pb->num,&pb->age);
if(i==0)
pf=head=pb;
else pf->next=pb;
pb->next=NULL;
pf=pb;
}
return(head);
}
void main()
{
struct stu *head = NULL;
int n = 0;
scanf("%d", &n);
head = creat(n);
}
这样应该可以了。
#define LEN sizeof (struct stu)
struct stu
{
int num;
int age;
struct stu *next;
};
TYPE *creat(int n)
{
struct stu *head,*pf,*pb;
int i;
for(i=0;i<n;i++)
{
pb=(TYPE*) malloc(LEN);
printf("input Number and Age\n");
scanf("%d%d",&pb->num,&pb->age);
if(i==0)
pf=head=pb;
else pf->next=pb;
pb->next=NULL;
pf=pb;
}
return(head);
}
void main()
{
struct stu *head = NULL;
int n = 0;
scanf("%d", &n);
head = creat(n);
}
这样应该可以了。
- C链表回顾
- 关于链表[回顾]
- 链表回顾
- 链表结构回顾
- 链表基础 回顾
- C、C++、Java回顾
- C/C++ 知识点回顾 双向链表的创建、插入和删除
- C语言回顾
- c/c++ 回顾
- 1回顾C/C++
- 1回顾C/C++
- C语言回顾
- c语言基础知识回顾
- C语言回顾
- C语言指针回顾
- C基本题回顾
- C语言基础回顾
- 开始回顾C/C++
- 用C#编写网页小应用程序(Applet)
- iOS:UIView属性、方法及相关
- 遇见phpDesigner我笑了 PHP开发利器
- HDU1757-矩阵相乘
- 判断数字是否是回文
- C链表回顾
- 数据库锁及死锁的概念
- 求两个整形数组的异集
- Linux 信号signal处理机制
- c语言内存泄露示例
- 这18条背下来没人敢和你忽悠CPU
- UVA 10192 Vacation(dp + LCS)
- VMware9虚拟机安装MAC OS X Mountain Lion 10.8.2详细图文教程
- LeetCode 3: Longest Substring Without Repeating Characters