#include <stdio.h>
struct list
{
int data;
int cur;
}SListLink[100];
void CreatList (struct list *table)
{
int i, j;
i = 0;
for(j = 0; j < 5; j++)
{
scanf("%d%d", &(table[i].data), &(table[i].cur));
i = table[i].cur;
}
}
void InsertList (struct list *table, int i, int n)
{
int j = 0;
while(i--)
{
j = table[j].cur;
}
table[10].data = n;
table[10].cur = table[j].cur;
table[j].cur = 10;
}
void PrintList (struct list *table)
{
int i = 0;
for(; table[i].cur != 0; i = table[i].cur)
{
printf("%d\n", table[i].data);
}
}
int main ()
{
CreatList(SListLink);
PrintList(SListLink);
InsertList(SListLink, 3, 10);
PrintList(SListLink);
return 0;
}
静态链表
最新推荐文章于 2024-06-28 13:38:22 发布