Salvo ho un problema con un programma:
Questo è il codiche del file squadra.c:
codice:
/****************************************************************************/
/* LIBRERIE */
/****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "squadra.h"
int calcolapuntgio(int r,int a,int c,int p,int ca,int co,int re){
int prod;
prod=(r*a)+(r*c)+(r*p)+(r*ca)+(r*co)+(r*re);
return prod;
}
/****************************************************************************/
/* INSERIMENTO IN LISTA */
/****************************************************************************/
void inserisci_l(pnodo *L, char *nome,int tot,int per)
{
pnodo aus = NULL,
tmp = NULL;
if (( aus = (pnodo) malloc (sizeof(struct nodo) ) ) == NULL )
fprintf(stderr,"ERRORE overflow %d\n");
else{
aus->nome = nome;
aus->totsq = tot;
aus->fatmolt = (per*100)/5;
aus->punteggio = (aus->totsq)*(aus->fatmolt);
aus->next = NULL;
if(*L == NULL)
*L = aus;
else{
tmp = *L;
while(tmp->next)
tmp = tmp->next;
tmp->next = aus;
}
}
}
/****************************************************************************/
/* STAMPA LISTA */
/****************************************************************************/
void print_l(pnodo L){
while (L != NULL){
printf(" %s %d %d %d\n",L->nome,L->totsq,L->fatmolt,L->punteggio);
L = L->next;
}
printf("NULL\n");
}
Questo è il codice del file squadra.h
codice:
/* LISTA */
typedef struct nodo *pnodo;
struct nodo{
char *nome;
int totsq;
int fatmolt;
int punteggio;
pnodo next;
};
void inserisci_l(pnodo *L, char *n,int t,int f);
int calcolapuntgio(int a,int b,int c,int d, int e,int f,int h);
void print_l(pnodo L);
Per inserire i dati uso
inserisci_l(&lista,nsq,totsq,vit);
dove prima pongo
pnodo lista=NULL;
Il mio problema è come faccio a creare una funzione che prende in input l'intera lista e un nome e restituisce il punteggio corrispondente a quel nome?
Grazie in anticipo a chi mi risponderà!!!