| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 735 人关注过本帖
标题:刚刚看了链表的看不怎么懂,求解释,再求仔细点
取消只看楼主 加入收藏
一只失语的猫
Rank: 2
等 级:论坛游民
帖 子:35
专家分:14
注 册:2011-10-26
结帖率:88.89%
收藏
已结贴  问题点数:10 回复次数:1 
刚刚看了链表的看不怎么懂,求解释,再求仔细点
#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
    long num;
    float score;
    struct student * next;
};
int n;
struct student * creat(void)
{
    struct student * head;
    struct student * p1, * p2;
    n = 0;
    p1 = p2 = (struct 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 = (struct student *)malloc(LEN);
        scanf ("%ld,%f",&p1 -> num, &p1 -> score);
    }
    p2 -> next = NULL;
    return (head);
}
搜索更多相关主题的帖子: include 
2011-11-15 12:49
一只失语的猫
Rank: 2
等 级:论坛游民
帖 子:35
专家分:14
注 册:2011-10-26
收藏
得分:0 
int n;
struct student * creat(void)
{
    struct student * head;
    struct student * p1, * p2;
    n = 0;
    p1 = p2 = (struct 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 = (struct student *)malloc(LEN);
        scanf ("%ld,%f",&p1 -> num, &p1 -> score);
    }
    p2 -> next = NULL;
    return (head);
}
2楼的大哥, 我这后面的都是看的模模糊糊的
2011-11-15 14:05
快速回复:刚刚看了链表的看不怎么懂,求解释,再求仔细点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039178 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved