蛋帮吧 关注:10贴子:473
  • 0回复贴,共1

【C++】单项链表的操作

只看楼主收藏回复

#include"iostream.h"
#include"stdio.h"
struct Students
{
int No;
char Name[16];
struct Students* next;
};
Students Stu[4] =
{
{001,"zhangsan"},
{002,"lisi"},
{003,"wangwu"},
{004,"xiaoliu"}
};
void main()
{
Stu[0].next = &Stu[1];
Stu[1].next = &Stu[2];
Stu[2].next = &Stu[3];
Stu[3].next = NULL;
Students* p = &Stu[0];
while(p!=NULL)
{
cout<<p->No<<" "<<p->Name<<endl;
p=p->next;
}
}


IP属地:江苏1楼2015-12-26 13:34回复