标题:这个怎么回事,老不对
取消只看楼主
see235959850
Rank: 2
等 级:论坛游民
帖 子:380
专家分:29
注 册:2016-12-21
结帖率:100%
 问题点数:0 回复次数:0 
这个怎么回事,老不对
程序代码:
#include<stdio.h>
#include<stdlib.h>
#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_s("%ld%f", &p1->num, &p1->score);
    while (p1->num != 0)
    {
        n = n + 1;
        if (n == 1)
            head = p1;
        else
            p2->next = p1;
        p2 = p1;
        p1 = (struct student *)malloc(len);
        scanf_s("%ld%f", &p1->num, &p1->score);
    }
    p2->next = NULL;
    return head;
}

int main()
{
    struct student *pt;
    pt = creat();
    printf("\nnum:%ld\nscore:%5.1f\n", pt->num, pt->score);
    return 0;
}
搜索更多相关主题的帖子: color 
2017-02-01 14:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-473920-1-1.html




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

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