更啦 当然我学c++
#include
<iostream>
using namespace std ;
typedef struct ss
{
using namespace std ;
typedef struct ss
{
int x;
struct ss *next;
}ss;
int main()
{
ss *pTmp,*pCurrent,*pHead;
for ( int i= 0 ;i< 5 ;i++)
{
pTmp= new ss ;
if (i== 0 )
{
pHead=pTmp;
}
else
int main()
{
ss *pTmp,*pCurrent,*pHead;
for ( int i= 0 ;i< 5 ;i++)
{
pTmp= new ss ;
if (i== 0 )
{
pHead=pTmp;
}
else
{
pCurrent->next=pTmp;
}
pCurrent=pTmp;
pCurrent-> x =i+ 1 ;
}
pCurrent=pHead;
while (pCurrent)
{
pCurrent=pTmp;
pCurrent-> x =i+ 1 ;
}
pCurrent=pHead;
while (pCurrent)
{
cout<<pCurrent->x<<endl;
pCurrent=pCurrent->next;
}
return 0 ;
return 0 ;
}
不难看出是链表啊
创建结构体,0时设表头,赋值然后指,一个一个打。
(1)创建结构体,往往在里面放上数字(好看),再放一个指针。
(2)在循环0时,要定连表头。
(3)其实就是指和赋值,先把里面的小指针指过去,在自己过去。
(4)用while打就好啦,记得前面要弄成链表头。