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

时间:2014-11-04 22:27:31   收藏:0   阅读:197

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

bubuko.com,布布扣

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);

}

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!