Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //listát csinál a két fájlból
- //strázya nélküli listát alkalmazunk
- #include <stdio.h>
- typedef struct jarmu
- {
- //Adatok
- char rendszam[7 + 1];
- char gyarto[7 + 1];
- char tipus[7 + 1];
- int evjarat;
- char szin[7 + 1];
- int ferohely;
- int hengerur;
- int teljesitmeny;
- //Jellemzők
- char szarmazas[7 + 1];
- int kilometer;
- int hibakod;
- int allapot;
- int elado;
- int ar;
- }jarmu;
- typedef struct listelem
- {
- jarmu data;
- struct listelem* next;
- }listelem;
- listelem* beszurHatra(listelem* list, jarmu data)
- {
- if (list == NULL)
- {
- listelem* uj = (listelem*)malloc(sizeof(listelem));
- uj->next = NULL;
- uj->data = data;
- return uj;
- }
- else
- {
- listelem* p = list;
- while (p->next != NULL)
- {
- p = p->next;
- }
- listelem* uj = (listelem*)malloc(sizeof(listelem));
- uj->next = NULL;
- uj->data = data;
- p->next = uj;
- }
- }
- void kiir(listelem* list)
- {
- listelem* p = list;
- while (p->next != NULL)
- {
- printf("%s\t%s\t%s\t%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t", list->data.rendszam, list->data.gyarto, list->data.tipus, list->data.evjarat, list->data.szin, list->data.ferohely, list->data.hengerur, list->data.teljesitmeny, list->data.kilometer, list->data.hibakod, list->data.allapot, list->data.elado);
- p = p->next;
- }
- if (list->data.elado == 1)
- {
- printf("%d\n", list->data.ar);
- }
- else
- {
- printf("\n");
- }
- }
- int main()
- {
- //lista létrehozása
- listelem *list = NULL;
- FILE* adatok;
- FILE* jellemzok;
- adatok = fopen("adatok.txt", "r");
- jellemzok = fopen("jellemzok.txt", "r");
- jarmu read;
- while (fscanf(adatok, "%s\t%s\t%s\t%d\t%s\t%d\t%d\t%d", read.rendszam, read.gyarto, read.tipus, &read.evjarat, read.szin, &read.ferohely, &read.hengerur, &read.teljesitmeny) == 8 && fscanf(jellemzok, "%s\t%s\t%d\t%d\t%d\t%d\t%d", read.rendszam, read.szarmazas, &read.kilometer, &read.hibakod, &read.allapot, &read.elado, &read.ar) == 7)
- {
- list = beszurHatra(list, read);
- }
- fclose(adatok);
- fclose(jellemzok);
- kiir(list);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement