#include #include #include typedef struct numType { int num; struct numType *next; }node; typedef struct stringType { char string[80]; struct stringType *next; }stringRecord, *stringPtr; void main() { node *head, *pos; int done = 1; int temp; node *p, *q; stringPtr headS, posS, r,s; int i,m=0,n=0; head = (node*)malloc(sizeof(node)); head->num = 2; pos = (node*)malloc(sizeof(node)); head->next = pos; pos->num = 4; pos->next = (node*)malloc(sizeof(node)); pos->next->num = 7; pos = pos->next; pos->next = (node*)malloc(sizeof(node)); pos->next->num = 1; pos->next->next = head; head = pos->next; headS = (stringPtr)malloc(sizeof(stringRecord)); strcpy(headS->string,"abc"); posS = (stringPtr)malloc(sizeof(stringRecord)); headS->next = posS; strcpy(posS->string,"hello"); posS->next = (stringPtr)malloc(sizeof(stringRecord)); posS = posS->next; posS->next = (stringPtr)malloc(sizeof(stringRecord)); strcpy(posS->string,"the"); posS = posS->next; posS->next = (stringPtr)malloc(sizeof(stringRecord)); strcpy(posS->string,"Hi"); posS = posS->next; posS->next = (stringPtr)malloc(sizeof(stringRecord)); strcpy(posS->string,"surviving"); posS = posS->next; posS->next = (stringPtr)malloc(sizeof(stringRecord)); strcpy(posS->string,"string"); posS = posS->next; posS->next = (stringPtr)malloc(sizeof(stringRecord)); strcpy(posS->string,"bye"); posS = posS->next; posS->next = headS; headS = posS; s = headS; posS = headS->next; printf("%s ", posS->string); posS = posS->next; while (posS != headS) { printf("%s ", posS->string); posS = posS->next; } do { p = head->next; done = 1; while (/*1*/p!=head) { q = p->next; if (p->num > q->num) { temp = p->num; p->num = q->num; q->num = temp; done = 0; } p = p->next; } } while (/*2*/done!=1); //print list pos = head->next; printf("%d ", pos->num); pos = pos->next; while (pos != head->next) { printf("%d ", pos->num); pos = pos->next; } if (head) { s = headS; do { p = p->next; n = p->num; for (i = m; inext; r = s->next; /*3*/; free(r); m = /*4*/; } while (p !=head); } posS = headS->next; printf("%s ", posS->string); posS = posS->next; while (posS != headS->next) { printf("%s ", posS->string); posS = posS->next; } getch(); }