# Include <stdio. h> # include <stdlib. h ># include <iostream> using namespace STD; Template <class T> struct entry; Template <class T> struct link_head {entry <t> * Next; int size ;}; template <class T> struct entry {entry <t> * Next; T * element;}; Template <class T> link_head <t> * create_link (T * array, int N) {link_head <t> * head = new link_head <t>; entry <t> ** PTR = & head-> next; For (INT I = 0; I <N; ++ I) {entry <t> * entry_elem = New entry <t>; T * element = new T (array [I]); entry_elem-> element = element; * PTR = entry_elem; PTR = & entry_elem-> next;} * PTR = NULL; head-> size = N; return head;} template <class T> voidprint_link (link_head <t> * head) {entry <t> * entry = head-> next; while (entry! = NULL) {cout <* entry-> element <Endl; entry = entry-> next;} template <class T> voidlink_sort (link_head <t> * head) {entry <t> * P = head-> next; entry <t> * r; // R is the next entry of P <t> * q; head-> next = NULL; while (P! = NULL) {r = p-> next; q = (Entry <t> *) head; while (Q-> next! = NULL & * q-> next-> element <* P-> element) {q = Q-> next;} p-> next = Q-> next; q-> next = P; P = r ;}} intmain () {int array [] = {20, 3, 40, 5, 6, 89, 9 }; int n = sizeof (array)/sizeof (INT); link_head <int> * head = create_link (array, n); link_sort (head); print_link (head );}