| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 465 人关注过本帖
标题:如何逆序链表?
取消只看楼主 加入收藏
henji
Rank: 1
等 级:新手上路
帖 子:227
专家分:0
注 册:2009-4-19
结帖率:38.67%
收藏
已结贴  问题点数:10 回复次数:0 
如何逆序链表?
#include "stdio.h"
#include "string.h"
#include "malloc.h"
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
    long num;
    float score;
    char name[20];
    struct student *next;
};
int n;

struct student * create(void)
{
    struct student *head;
    struct student *p1,*p2;
    n=0;
    p1=(struct student *)malloc(LEN);
    scanf("%ld,%f,%s",&p1->num,&p1->score,p1->name);
    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,%s",&p1->num,&p1->score,&p1->name);
    }
    p2->next=NULL;
    return (head);
}

struct print(struct student *head)
{
    struct student *p;
    printf("\nNow,These %d records are:\n",n);
    p=head;
    if(head!=NULL)
    {
        do
        {
            printf("%ld%5.1f%4s\n",p->num,p->score,p->name);
            p=p->next;
        }while(p!=NULL);
    }
}

struct nixu(struct student *head)//这段函数该如何些逆序链表的代码?
{
    
    
}
int main(int argc, char* argv[])
{
    struct student *head,stu;
    long del_num;
    printf("input records:\n");
    head=create();
    print(head);
    return 0;
}
搜索更多相关主题的帖子: 逆序 链表 
2009-08-05 15:38
快速回复:如何逆序链表?
数据加载中...
 
   



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

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