用数组实现单链表
程序员文章站
2022-06-06 13:34:51
...
#include<iostream>
#include<malloc.h>
using namespace std;
typedef struct st
{
int data;
struct st *next;
}st;
int main()
{
st a[3] = { 5,&a[1],7,&a[2],9,NULL };
st *p = a;
while (p != NULL)
{
cout <<" "<< p->data <<" ";
p = p->next;
}
cout << endl;
return 0;
}