| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 311 人关注过本帖
标题:动态链表,帮忙看下哪错了?
取消只看楼主 加入收藏
klfy6666
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2010-4-23
结帖率:0
收藏
已结贴  问题点数:5 回复次数:0 
动态链表,帮忙看下哪错了?
#include<stdio.h>
#include<stdlib.h>
struct student
{
    int num;
    float score;
    struct student *next;
};
struct student *head,*p1,*p2;
void main()   
    {
   
    p1=(struct student *)malloc(sizeof(struct student));
    scanf("%d,%f",&p1->num,&p1->score);
    head=p1;
    p2=head;
    while(p1->num!=0)
    {        
        p1=(struct student *)malloc(sizeof(struct student));
        scanf("%d,%f",&p1->num,&p1->score);
        p2->next=p1;
        p2=p1;
        
    }
        p2->next=NULL;   
    while(p1!=NULL)
    {
    printf("%d,%f\n",p1->num,p1->score);
    p1=p1->next;
    }
}
2010-12-27 20:13
快速回复:动态链表,帮忙看下哪错了?
数据加载中...
 
   



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

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