#include <iostream> struct StackFrame { int data; StackFrame* link; }; typedef StackFrame * StackFramePtr; void reverse( StackFramePtr head ); using namespace std; int main() { int number = 0; StackFramePtr head, temp, p; head = new StackFrame; p=head; cout << "enter numbers, end with -1"<<endl; cin >> number; while( number > 0 ) { StackFramePtr ss=new StackFrame; ss->data=number; ss->link=NULL; p->link=ss; p=ss; cin >> number; } temp = head->link; cout << "list as entered: " << endl; while( NULL != temp ) { cout << temp->data << endl; temp = temp->link; } cout << "calling reverse" << endl; reverse( head ); temp = head->link; cout << "list reversed: " << endl; while( NULL != temp ) { cout << temp->data << endl; temp = temp->link; } return 0; } void reverse( StackFramePtr head ) { StackFramePtr temp,last; last = head; int tt=0; while ( NULL != last->link ) { last=last->link; tt++; } temp=head->link; int ii=0; while(ii < tt/2) { int tt; tt=temp->data; temp->data=last->data; last->data=tt; temp++; last--; ii++; } }