| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1032 人关注过本帖
标题:单链表问题中插入,删除问题
取消只看楼主 加入收藏
yaorongfu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-3-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
单链表问题中插入,删除问题
#include<stdio.h>
typedef struct student{
    int data;
    long number;
    char name;
    char sex;
    int age;
    struct student*next;
}LIST;
LIST *CreatLList(int n)
{        LIST *head,*p,*q;
          int i;
if(n>0)
{
    head=(LIST *)malloc(sizeof(LIST));
    printf("请输入第一个学生信息:\n");
        scanf("%ld%s%s%d",&head->number,&head->name,&head->sex,&head->age);
    p=head;
    for(i=2;i<=n;i++)
    {
        q=(LIST *)malloc(sizeof(LIST));
        printf("请输入第一个学生信息:\n");
            scanf("%ld%s%s%d",&q->number,&q->name,&q->sex,&q->age);
        p->next=q;p=q;}
    q->next=NULL;}

else
head=NULL;
return head;
}

void OutputLList(LIST *p)
{
        
    printf("\n输出信息:\n");
    while(p){
        printf("学号:%d,姓名:%s,性别:%s,年龄:%d\n",
            p->number,p->name,p->sex,p->age);
        p=p->next;
    }
}

LIST *InsertLList(LIST *p, LIST *newnode,int iPos)
{

   
   
}
LIST *DeleteLList(LIST *p,int iPos)
{
   
   
   
   
}

int FindLList(LIST *p,int age)
{
   
}
(3) 向链表指定位置插入新结点 函数原型:LIST *InsertLList(LIST *p, LIST *newnode,int iPos); 函数参数:p为单链表头指针 newnode指向要插入的新节点 iPos为插入位置,将新节点插在第iPos个位置,若表中无第iPos个结点,则给出相应提示信息。头结点位置为0。 返回值: 单链表头指针
(4) 删除链表指定位置的结点 函数原型:LIST *DeleteLList(LIST *p,int iPos); 函数参数:p为单链表头指针 iPos 为指定位置,若表中无第iPos结点,则给出相应提示信息。头结点位置为0。 返回值: 单链表头指针
(5) 查找与给定年龄age相同的记录 函数原型:int FindLList(LIST *p,int age); 函数参数:p为单链表头指针 age 为查找条件 返回值: 查找成功,返回该结点所在位置信息,头结点位置为0。 查找失败,返回-1。后三个实在编不出来
搜索更多相关主题的帖子: long next include number 
2013-03-31 18:16
快速回复:单链表问题中插入,删除问题
数据加载中...
 
   



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

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