int main(){ int a[6] = {1,2,3,4,5,6}; int i; insertion_sort_desc(a,6); for(i=0;i<5;i++) assert(a[i] > a[i+1]); insertion_sort_asc(a,6); for(i=0;i<5;i++) assert(a[i] < a[i+1]); return 0; }
int main(void) { int num, control = 1, count = 0; node *head, *head1, *head2, *p, *p1; head = NULL; head1 = NULL; /* allows user to input elements and counts them*/ printf("Enter an integer or multiple integers separated by a space.\n"); printf(" Type any character to quit input\n"); while (control == 1) { control = scanf("%d", &num); if (control != EOF && control > 0) { head = insertion_sort_asc(head, num); head1 = insertion_sort_des(head1, num); head2 = first_in_first_out(head2, num); } count++; } count--; /* prints out different linked lists and count of elements*/ if (control == 0) { printf("Read %d items", count); print(head, p); print(head1, p); print(head2, p); printf("\n"); } else if (control == EOF) { printf("\nRead %d items", count); print(head, p); print(head1, p); print(head2, p); printf("\n"); } return 0; }