#include<iostream>
#include<stdio.h>
using namespace std;
const int MAX = 100;
typedef struct node
{
int data;
int next;
}node;
node arr[MAX];
int create(node *a);
void myprintf(node *a);
int
main(void)
{
int len=create(arr);
myprintf(arr);
return 0;
}
int create(node *a)
{
int i=0,temp;
while(~scanf("%d",&temp)&& temp!=-1)
{
a[i].data = temp;
a[i].next=i+1;
i++;
}
a[i-1].next=-1;//end
return i;
}
void myprintf(node *a)
{
int pos=0;
while(pos!=-1)
{
printf("%d ",a[pos].data);
pos = a[pos].next;
}
}
静态链表
最新推荐文章于 2025-04-17 12:52:44 发布