#include <cstdlib>
#include <iostream>
using namespace std;
class node
{
public:
int data;
node *link;
};
void fo(node *p) //輸出
{
while(p!=NULL)
{
cout<<p->data<<endl;
p=p->link;
}
}
node *invert1(node *first)
{
node *p=first;
node *x0=NULL,*s1;
while(p!=NULL)
{
s1=p->link;
p->link=x0;
x0=p;
p=s1;
}
first=x0;
return first;
}
int main(int argc, char *argv[])
{
node *a=new node,*b = new node, *c=new node;
node *first=a;
a->data=10;
b->data=20;
c->data=30;
a->link=b;
b->link=c;
c->link=NULL;
fo(first);
first=invert1(first);
fo(first);
system("PAUSE");
return EXIT_SUCCESS;
}