Guest User

Untitled

a guest
Jun 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 6
  4. typedef int giocata[N];
  5. typedef struct elem{
  6.     giocata* info;
  7.     struct elem* next;
  8. }elist;
  9. typedef elist* plist;
  10.  
  11. void aggiungi(plist* p, giocata g){
  12.     plist temp = (plist)malloc(sizeof(elist));
  13.     temp->info = &g;
  14.     temp->next = *p;
  15.     *p = temp;
  16. }
  17.  
  18. int vincente(giocata e, giocata g){
  19.     int i,j;
  20.     int cont = 0;
  21.     for(i=0;i<N && cont<3;i++){
  22.         j=0;
  23.         for(j=0;j<N && g[i]>=e[j];i++){
  24.             if(g[j] == e[i])
  25.                 cont++;
  26.             j++;
  27.         }
  28.     }
  29.     return(cont==3);
  30. }
  31.  
  32. int quantivin(giocata e, plist g){
  33.     int cont = 0;
  34.     while(g!=NULL){
  35.         if(vincente(e,g->info))
  36.             cont++;
  37.         g = g->next;
  38.     }
  39.     return cont;
  40. }
  41.  
  42. void stampagioc(giocata g){
  43.     int i;
  44.     for(i=0;i<6;i++)
  45.         printf("%d\t",g[i]);
  46.     printf("\n");
  47. }
  48.  
  49. void stampa(plist g){
  50.     printf("le giocate sono:\n");
  51.     while(g!=NULL){
  52.         stampagioc(*(g->info));
  53.         g = g->next;
  54.     }
  55.    
  56. }
  57.              
  58. main(){
  59.     plist p = NULL;
  60.     giocata uno = {40,50,60,70,80,90};
  61.     giocata due = {2,4,6,8,10,12};
  62.     giocata tre = {1,2,4,8,16,32};
  63.     giocata e = {1,2,16,18,32,80};
  64.     aggiungi(&p,&uno);
  65.     aggiungi(&p,&due);
  66.     aggiungi(&p,&tre);
  67.     stampa(p);
  68.     getch();
  69. }
Add Comment
Please, Sign In to add comment