int main() { int a = 0; int b = 0; int tmp = 0; List* listLess = createList(); List* listBetween = createList(); List* listMore = createList(); printf("Enter a\n"); scanf("%d",&a); printf("Enter b \n"); scanf("%d",&b); FILE* f = fopen("input.txt","r"); FILE* g = fopen("output.txt","w"); while (!(feof(f))) { fscanf(f,"%d",&tmp); if (tmp < a) add(listLess,tmp); if ((a <= tmp) && (tmp <= b)) add(listBetween,tmp); if (tmp >= b) add(listMore,tmp); } printListToFile(listLess,g); fprintf(g," | "); printListToFile(listBetween,g); fprintf(g," | "); printListToFile(listMore,g); destroyList(listLess); destroyList(listBetween); destroyList(listMore); fclose(f); fclose(g); printf("See output file\n"); getc(stdin); }
void executeChoice(int choice, Node ** head) { char * fn = NULL; char * fName = NULL; char * lName = NULL; char * position = NULL; switch(choice) { case 1: printList(*head); break; case 2: fn = getFileName(); FILE* fout = openKnownFile(fn,"w"); printListToFile(*head,fout); fclose(fout); break; case 3: getPositionUser(&position); printSpecificPlayers(*head, position); free(position); break; case 4: *head = sortList(*head, 1); break; case 5: *head = sortList(*head, 2); break; case 6: getPlayerName(&fName,&lName); removeNode(head,fName,lName); free(fName); free(lName); break; default: printf("Sorry incorrect input"); } }