Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- #include <stdio.h>
- #include "tlista.h"
- #include <stdlib.h>
- TLista Citire(size_t *lg)
- {
- TLista L = NULL, aux, u;
- TStudent x;
- *lg = 0;
- while( scanf("%s %d", x.nume, &x.nota) != EOF)
- {
- aux = AlocCelula(x);
- if (!aux) return L;
- if (!L)
- {
- L = aux;
- u = L;
- }
- else {
- u->urm = aux;
- u=aux;
- }
- *(lg)++;
- }
- return L;
- }
- TLista CitireOrdNume(size_t *lg) {
- TLista L = NULL,aux,u;
- TStudent x;
- *lg = 0;
- char c;
- while (scanf("%s %d",x.nume,&x.nota) != EOF) {
- aux=AlocCelula(x);
- if (!aux) return L;
- else {
- if (!L || strcmp(x.nume , L->info.nume) < 0) {
- if (L) aux->urm = L;
- L=aux;
- }
- else {
- u = L;
- while (u->urm && strcmp(u->urm->info.nume , x.nume) < 0) {
- u=u->urm;
- }
- aux->urm=u->urm;
- u->urm = aux;
- }
- }
- (*lg)++;
- }
- return L;
- }
- TLista CitireOrdNote(size_t *lg) {
- TLista L = NULL,aux,u;
- TStudent x;
- *lg = 0;
- char c;
- while (scanf("%s %d",x.nume,&x.nota) != EOF) {
- aux=AlocCelula(x);
- if (!aux) return L;
- else {
- if (!L || x.nota < L->info.nota) {
- if (L) aux->urm = L;
- L=aux;
- }
- else {
- u = L;
- while (u->urm && u->urm->info.nota < x.nota) {
- u=u->urm;
- }
- aux->urm=u->urm;
- u->urm = aux;
- }
- }
- (*lg)++;
- }
- while ((c=getchar())!=EOF&&c!= '\n');
- return L;
- }
- int main()
- {
- TLista x,y;
- size_t lx,lg;
- y = CitireOrdNote(&lx);
- printf("\n");
- x = CitireOrdNume(&lg);
- AfisareL(x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement