HERES MY CODE:
Code:#include <stdio.h> /* for printf */ #include <stdlib.h> /* for malloc */ typedef struct node { char player_id[7]; int level; int score; struct node *next; /* pointer to next element in list */ } *LIST; LIST new_list() // Create new list by creating sentinel node { LIST list = (LIST) malloc(sizeof(struct node)); list->next = NULL; return list; } // Add node to beginning of list LIST list_add(LIST list, int i) { LIST new_node = (LIST) malloc(sizeof(struct node)); if (new_node == NULL) return NULL; new_node->score = i; new_node->next = list; return new_node; } LIST list_remove(LIST list) /* remove node */ { LIST n; if (list->next == NULL) { return list; } if (list != NULL) { n = list->next; free(list); return n; } else return NULL; } LIST *sortlist(LIST list) { LIST sorted; if (list !=NULL) } void list_print(LIST list) { if (list == NULL) { printf("list is empty\n"); } while (list != NULL) { printf("score: %d\n", list->score); list = list->next; } } int main(void) { LIST slist; int len = 5; int i, array[len]; slist = new_list(); for (i = 0; i < len; i++) { printf("Enter a score: "); scanf("%d", &array[i]); //printf("%d\n", array[i]); slist = list_add(slist, array[i]); } list_print(slist); return 0; }
I dont know what to put in *sortlist..
How do I do it!? please help



LinkBack URL
About LinkBacks


