Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main.c - Ordinamento
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include "ordinamento.h"
- int main(int argc,char *argv[]) {
- double valore = 0;
- double numero = 0;
- FILE *mfptr = NULL;
- Node *head = NULL;
- if ( (mfptr = fopen(argv[1], "r") ) == NULL) {
- printf ("Impossibile aprire questo file\n");
- }
- else {
- while (!feof (mfptr)) {
- Node *el = malloc (sizeof(Node));
- fscanf(mfptr,"%le\n",&valore);
- el->valore = valore;
- el->next = NULL;
- inserisci(&head, el);
- }
- printf ("Lista senza indice NON ordinata: \n");
- stampa(head);
- printf("\n");
- ordina (&head);
- assegna_id(&head);
- printf ("Lista con indice e ordinata: \n");
- stampa(head);
- }
- numero = strtod (argv[2] , NULL);
- fclose(mfptr);
- return trova_id(&head , (int) numero);
- }
Advertisement
Add Comment
Please, Sign In to add comment