Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. struct listcampionato {
  6.    char *Nome;
  7.    int Punti;
  8.    int GF;
  9.    int GS;
  10.    struct listcampionato *next;
  11.    };
  12. typedef struct listcampionato ListaCampionato;
  13. typedef ListaCampionato *Campionato;
  14.  
  15.  
  16.  
  17. /*DICHIARO FUNZIONI*/
  18. void Elenco();
  19. void AggiungiSquadra(Campionato *,char *);
  20. void Stampa(Campionato ) ;
  21.    
  22. int main()
  23. {
  24. Campionato head=NULL;
  25. int choise=0;
  26. int scegli;
  27. char team[100];
  28. Elenco();
  29. while(choise==0)
  30. {
  31.    
  32.    printf("Scegli cosa fare : ");
  33.    scanf("%d",&scegli);
  34.    switch(scegli)
  35.    {
  36.        case 1:
  37.              printf("Che squadra vuoi inserire ? ");
  38.              scanf("%s",team);
  39.              AggiungiSquadra(&head,team);
  40.              Stampa(head);
  41.              break;
  42.       case 4:
  43.              Stampa(head);
  44.              choise=1;
  45.              break;
  46.              
  47.    }
  48. }
  49. return 0;
  50. }
  51.          
  52.        
  53.    
  54.        
  55. void Elenco()
  56. {
  57.  printf("Scegli cosa fare: \n 1)Inserisci squadra \n 2)Partita \n 3)PlayOff \n 4)Stampa \n");
  58.  }
  59.  
  60.  
  61. void AggiungiSquadra(Campionato *s,char *team)
  62. {
  63.  Campionato squadra;
  64.  squadra=malloc(sizeof(ListaCampionato));
  65.  squadra->Nome=team;
  66.  squadra->Punti=0;
  67.  squadra->GF=0;
  68.  squadra->GS=0;
  69.  squadra->next=*s;
  70.  *s=squadra;
  71. }
  72.  
  73. void Stampa(Campionato head)
  74. {
  75.  if(head==NULL)
  76.  {
  77.     printf("Campionato privo di squadre...\n");
  78.  }
  79.  else
  80.  {
  81.    while(head != NULL)
  82.    {
  83.     printf("Nome:%s\tPunti:%d\tGF:%d\tGS:%d\n",head->Nome,head->Punti,head->GF,head->GS);
  84.     head=head->next;
  85.    }
  86.   }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement