教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 教育文库 >

c语言数据结构静态链表

来源:网络收集 时间:2026-09-08
导读: c语言数据结构静态链表 #includestdio.h #includestring.h #includesys\timeb.h #include time.h #define N 50 typedef char ElemType[N]; #define MAX_LENGTH 100 typedef struct { ElemType data; int next; }LinkStatic[MAX_LENGTH]; void main() { timeb

c语言数据结构静态链表

#include<stdio.h>

#include<string.h>

#include<sys\timeb.h>

#include <time.h>

#define N 50

typedef char ElemType[N];

#define MAX_LENGTH 100

typedef struct

{

ElemType data;

int next;

}LinkStatic[MAX_LENGTH];

void main()

{

timeb t1,t2;

long t;

ftime(&t1);

printf("c语言中数据结构静态连表的演示!\n");

LinkStatic sl={{" ",1},{"I",2},{"am",3},{"a",4},{"student",0}}; int i=sl[0].next;

printf("输出初始化好的静态链表如下:\n");

while(i)

{

printf("%s ",sl[i].data);

i=sl[i].next;

}

printf("\n");

printf("在静态链表的第三个位置插入“not”!\n"); sl[2].next=5;

sl[5].next=3;

strcpy(sl[5].data,"not");

printf("输出插入元素后的静态链表:\n"); i=sl[0].next; while(i) { printf("%s ",sl[i].data); i=sl[i].next; } printf("\n"); printf("删除静态连表的第二个元素:\n"); sl[1].next=3; i=sl[0].next; printf("输出删除后的静态链表:\n");

c语言数据结构静态链表

while(i)

{

printf("%s ",sl[i].data);

i=sl[i].next;

}

printf("\n");

ftime(&t1);

t=(t2.time-t1.time)*1000+(t2.millitm-t1.millitm); printf("程序执行总时间%ld\n",t);

}

c语言数据结构静态链表.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/110427.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)