#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct student)
typedef struct student
{
long num;
float score;
struct student *next;
}student;
int n;
int main()
{
student *head;
student
*p1,*p2;
//printf("sizeof is %d",sizeof(head)); 果然不管如何指针都是四个字节的大小的存在
n = 0;
p1 = p2 = (student *)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
head = NULL;
while(p1->num != 0)
{
n = n+1;
if(n == 1)
head = p1;
else
p2->next = p1;
p2 = p1;
p1 = (student *)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
}
return 0;
}
当年所谓不解决的动态链表问题,再次回顾,呵呵
转载上一篇:数据段,代码段,BBS,堆,栈
下一篇:关于接口的一点儿小问题
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java解决if else过多的问题
java解决if else过多的问题
策略模式 工厂模式 ifelse 枚举 -
【数据结构】链式家族的成员——循环链表与静态链表
【数据结构】第二章——线性表(8)详细介绍了循环链表与静态链表的相关内容……
数据结构 C语言 循环链表 静态链表 -
再次回来!!!
再次回归51cto博客!!!
博客 开篇 知识记录;整理 -
go入口文件与包初始化(待再次回顾)
go入口文件与包初始化(待再次回顾)
go 初始化 源文件 标识符 -
Serializable和Parcelable的再次回忆
序列化和反序列化几乎是工程师们每天都要面对的事情,但是要精确
android Serializab Parcelable 序列化 反序列化