struct STU
{
int a;
STU *pNext;
};
struct STU *pStufirst = new STU;
pStufirst->a = 0;
struct STU *pStuCurrent = NULL;
pStuCurrent = pStufirst;
struct STU *pStu = NULL;
for(int i=0;i<10;i++)
{
pStu = new STU;
pStu->a = i+1;
pStuCurrent->pNext = pStu;
pStuCurrent = pStu;
pStuCurrent->pNext = NULL;
}
pStuCurrent = pStufirst;
while(pStuCurrent->pNext != NULL)
{
printf("%d\n",pStuCurrent->a);
fflush(stdout);
pStuCurrent = pStuCurrent->pNext;
}
//主要代码
pStu = NULL;
while (pStufirst)
{
STU* next = pStufirst->pNext;
pStufirst->pNext = pStu;
pStu = pStufirst;
pStufirst = next;
}
pStuCurrent = pStu;
while(pStuCurrent->pNext != NULL)
{
printf("%d\n",pStuCurrent->a);
fflush(stdout);
pStuCurrent = pStuCurrent->pNext;
}
单项链表倒序
最新推荐文章于 2019-10-27 10:58:42 发布