• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

尼古拉斯豆

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

数据结构--串--链式存储

#include <stdio.h>

struct node{
    char ch;
    struct node *next;
};

/* 1.初始化单链表*/
void init(struct Node **h)
{
    *h = (struct node *)mallov(sizeof(struct node));
    if(*h == NULL)
    {
        printf("空间申请失败...\n");    
        system("pause"); 
    }
    (*h)->next = NULL:
    return;    
}

/* 2.将x节点插入到链表后*/ 
void append(struct node *p, int x)
{
    struct node *s;
    s = (struct node *)malloc(sizeof(struct node));
    if(*h == NULL)
    {
        printf("空间申请失败...\n");    
        system("pause"); 
    }
    s->ch = x;
    while(p->next != NULL)
    {
        p = p->next;    
    }    
    p->next = s;
    return; 
} 

/* 3.打印串*/ 
void display(struct node *p)
{
    while(p->next != NULL)
    {
        printf("%c",p->next->ch);
        p=p->next;    
    } 
    printf(" ");
    
    return;   
} 

posted on 2012-07-09 15:38  尼古拉斯豆  阅读(242)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3