我写了一个,你看看吧。
                             //课后习题3-6  用单链表实现逆转;
#include <iostream>
using namespace std;
class List;                            //List类的前视声明;
class ListNode                         //ListNode类定义;
{
    friend class List;                 //List为友元类;
private:
    int data;                            
    ListNode *link;
public:
    ListNode(int d){data=d;link=0;}         //构造函数(空表);
};
class List                                  //List类定义;、
{
private:
    ListNode *first,*last;
public:
    List(){first=last=0;}                  //构造函数;
    void Insert(int);                      //插入函数:为链表赋值;
    void Inverse();
    void print(int);                        //输出函数;
};
void List::Insert(int i)
{
    ListNode *p=new ListNode(i);
    if(first==0)                           //原为空表;
    {
        first=last=p;
        last->link=NULL;
    }
    else
    {
        p->link=first;                     
        first=p;
    }
}
void List::Inverse()
{
    if(first==0)return;                         //原为空表时无逆转;
    ListNode *p=first->link,*pr=NULL;
    while(p!=NULL)
    {
        first->link=pr;                      //逆转第一个节点;
        pr=first;
        first=p;
        p=p->link;
    }
    first->link=pr;
}
void List::print(int n)                        //输出链表;
{
    ListNode *q=first;
    cout<<q->data<<' ';
    for(int i=0;i<n-1;i++)
    {
        q=q->link;
        cout<<q->data<<' ';
    }
    cout<<endl;
}
void main()
{
    List a;                                //定义对象a;
    int n;
    cout<<"请输入插入值的个数(n):"<<' ';
    cin>>n;
    for(int i=n;i>=1;i--)
    {
        a.Insert(i);
    }
    cout<<"原表为:"<<endl;
    a.print(n);
    a.Inverse();
    cout<<"逆转后表为:"<<endl;
    a.print(n);
}