首页 > 代码库 > C++之数据结构,单链表

C++之数据结构,单链表

用结构体构建单链表例子:

int main ()
{
  struct student head;
  struct student body;
  struct student end;
  struct student *p;

  head.a = 10;
  head.b = 20;

  body.a = 30;
  body.b = 40;

  end.a = 50;
  end.b = 60;

  head.next = &body;
  body.next = &end;
  end.next = NULL;

  p = &head;
  do{
    cout<<p->a<<p->b<<"\n";
    p = p->next;
  }while(p != NULL);

}

C++之数据结构,单链表