Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- struct listcampionato {
- char *Nome;
- int Punti;
- int GF;
- int GS;
- struct listcampionato *next;
- };
- typedef struct listcampionato ListaCampionato;
- typedef ListaCampionato *Campionato;
- /*DICHIARO FUNZIONI*/
- void Elenco();
- void AggiungiSquadra(Campionato *,char *);
- void Stampa(Campionato ) ;
- int main()
- {
- Campionato head=NULL;
- int choise=0;
- int scegli;
- char team[100];
- Elenco();
- while(choise==0)
- {
- printf("Scegli cosa fare : ");
- scanf("%d",&scegli);
- switch(scegli)
- {
- case 1:
- printf("Che squadra vuoi inserire ? ");
- scanf("%s",team);
- AggiungiSquadra(&head,team);
- Stampa(head);
- break;
- case 4:
- Stampa(head);
- choise=1;
- break;
- }
- }
- return 0;
- }
- void Elenco()
- {
- printf("Scegli cosa fare: \n 1)Inserisci squadra \n 2)Partita \n 3)PlayOff \n 4)Stampa \n");
- }
- void AggiungiSquadra(Campionato *s,char *team)
- {
- Campionato squadra;
- squadra=malloc(sizeof(ListaCampionato));
- squadra->Nome=team;
- squadra->Punti=0;
- squadra->GF=0;
- squadra->GS=0;
- squadra->next=*s;
- *s=squadra;
- }
- void Stampa(Campionato head)
- {
- if(head==NULL)
- {
- printf("Campionato privo di squadre...\n");
- }
- else
- {
- while(head != NULL)
- {
- printf("Nome:%s\tPunti:%d\tGF:%d\tGS:%d\n",head->Nome,head->Punti,head->GF,head->GS);
- head=head->next;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement