It's very simple. Just practice it.
1 // the reverse order of a single-chain table is actually very easy, that is, to point the pointer to a change, note several issues 2 // (1) if it is an element, it is not a header node, directly return 3 // (2) Note that the header node should handle the problem independently. 4 # include <iostream> 5 using namespace STD; 6 7 typedef struct linknode {8 int val; 9 linknode * Next; 10} node, * List; // Adding typedef indicates that node and list are of the type. Otherwise, it is only a struct variable 11 12 Void reverse (list head) 13 {14 if (Head = NULL | head-> next = NULL) 15 return; 16 node * P = head-> next; 17 node * q = p-> next; 18 node * T; 19 P-> next = NULL; 20 while (Q! = NULL) 21 {22 t = Q-> next; 23 Q-> next = P; 24 p = Q; 25 q = T; 26} 27 head-> next = P; 28} 29 List createlist () 30 {31 int data; 32 list head = new node; 33 head-> val = 0; 34 head-> next = NULL; 35 node * P = head; 36 while (CIN> data) 37 {38 node * TMP = new node; 39 TMP-> val = data; 40 TMP-> next = NULL; 41 P-> next = TMP; 42 p = TMP; 43} 44 return head; 45} 46 47 int main () 48 {49 node * head = createlist (); 50 reverse (head); 51 node * P = head-> next; 52 while (P) 53 {54 node * q = p-> next; 55 cout <p-> Val <""; 56 Delete P; 57 P = Q; 58} 59 cout <Endl; 60 system ("pause"); 61}