Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Sports meeting score statistics
Sports meeting score statistics
# include & ltmalloc.h & gt

# include & ltstdio.h & gt

# include & ltstdlib.h & gt

# include & ltstring.h & gt

# Define NULL 0

# define MaxSize 30

Typedef struct sports structure/* athletes */

{

char name[20];

Int score; /* Score */

Int range; /**/

Int item; /* Project */

} ATH;

Typedef structure school structure/* school */

{

Int count; /*No. */

Int serial; /**/

Int menscore/* Male players score */

Int womenscore/* female players score */

Int totalscore/* total score */

ATH athlete [maxsize]; /**/

struct schoolstruct * next

} SCH

int nsc、msp、wsp

int ntsp

int i,j;

int overgame

Int serial, range;

int n;

SCH *head,*pfirst,* psecond

int *phead=NULL,*pafirst=NULL,* pasecond = NULL

Enter ()

{

Char answers;

head =(SCH *)malloc(sizeof(SCH)); /**/

head->; next = NULL

Pfirst = head;

Answer =' y

While (answer == 'y')

{

Is_Game_DoMain:

Printf ("\ nGet the top 5 when odd \ nGet the top 3 when even");

Printf ("\ nEnter the sports item serial number (x

scanf("%d ",pa first);

overgame = * pafirst

If (pafirst! = phead)

{

for(pasecond = phead; pasecond & ltpafirstpassecond++)

{

if(over game = = * passecond)

{

Printf ("\ nThis item already exists; Please choose another number \ n ");

Goto is _ Game _ DoMain.

}

}

}

pa first = pa first+ 1;

if(over game & gt; ntsp)

{

Printf ("\ nProject does not exist");

Printf ("\ nPlease re-enter");

Goto is _ Game _ DoMain.

}

Switch (game over %2)

{

Case 0: n = 3; Break;

Case1:n = 5; Break;

}

for(I = 1; I < = n; i++)

{

Is_Serial_DoMain:

Printf ("\ nEnter the serial number of the number. % d (0

Scanf("%d ",& serial);

if(serial & gt; nsc)

{

Printf ("\ nThe number of schools exceeds, please re-enter");

Goto is _ Serial _ DoMain.

}

if(head-& gt; next == NULL)

{

create();

}

psecond = head-& gt; Next;

while(PS second! = empty)

{

if(psecond-& gt; Serial = = serial)

{

pfirst = psecond

p first-& gt; count = p first-& gt; Count+1;

goto Store _ Data

}

other

{

PS econd = PS econd-& gt; Next;

}

}

create();

Store _ data:

p first-& gt; Athletes [pfirst-> Count]. item = overgame

p first-& gt; Athletes [pfirst-> Count]. range = I;

p first-& gt; Serial = serial; ("Enter name:)");

scanf("%s ",p first-& gt; Athletes [pfirst-> Count]. Name);

}

Printf ("\ nContinue to enter sports items (y&; n)? ”);

answer = getch();

printf(" \ n ");

}

}

calculate() /**/

{

p first = head-& gt; Next;

while(p first-& gt; Au Suivant! = empty)

{

for(I = 1; I< = pfirst-> Count; i++)

{

if(p first-& gt; An athlete [me]. Item% 2 == 0)

{

Switch (pfirst->; An athlete [me]. Range)

{

Case1:pfirst-> An athlete [me]. Score = 5; Break;

Case 2: Pfirst-> An athlete [me]. Score = 3; Break;

Case 3: Pfirst-> An athlete [me]. Score = 2; Break;

}

}

other

{

Switch (pfirst->; An athlete [me]. Range)

{

Case1:pfirst-> An athlete [me]. Score = 7; Break;

Case 2: Pfirst-> An athlete [me]. Score = 5; Break;

Case 3: Pfirst-> An athlete [me]. Score = 3; Break;

Case 4: Pfirst-> An athlete [me]. Score = 2; Break;

Case 5: Pfirst-> An athlete [me]. Score =1; Break;

}

}

if(p first-& gt; An athlete [me]. item & lt=msp)

{

p first-& gt; menscore = p first-& gt; menscore+p first-& gt; An athlete [me]. Scores;

}

other

{

p first-& gt; women score = p first-& gt; women score+p first-& gt; An athlete [me]. Scores;

}

}

p first-& gt; total score = p first-& gt; menscore+p first-& gt; Female core;

p first = p first-& gt; Next;

}

}

Output ()

{

p first = head-& gt; Next;

psecond = head-& gt; Next;

while(p first-& gt; Au Suivant! = empty)

{

clr SCR();

Printf ("\ nResult of school number %d:", pFirst-> Serialized);

Printf ("\ n \ nNumber of projects \ tSchool name \ tscore");

for(I = 1; I<= ntspi++)

{

for(j = 1; j & lt= p first-& gt; Count; j++)

{

if(p first-& gt; Athlete [j]. item == i)

{

printf("\n %d\t\t\t\t\t\t%s\n %d ",I,p first-& gt; Athlete [j]. Name, pFirst-> Athlete [j]. Score); Break;

}

}

}

Printf ("\ n \ n \ n \ t \ t \ t \ t tPress any button to go to the next page ");

getch();

p first = p first-& gt; Next;

}

clr SCR();

Printf(" \ n \ n games result:\ n \ n \ nSchool number \ tMale athlete's score \ tFemale athlete's score \ tTotal score ");

p first = head-& gt; Next;

while(p first-& gt; Au Suivant! = empty)

{

printf("\n %d\t\t %d\t\t %d\t\t %d ",p first-& gt; Serial, pfirst->; menscore,p first-& gt; Female core, Pfirst-> total score);

p first = p first-& gt; Next;

}

Printf ("\ n \ n \ n \ t \ t \ t \ t \ tPress any button to end");

getch();

}

Create ()

{

p first =(struct school struct *)malloc(sizeof(struct school struct));

p first-& gt; next = head-& gt; Next;

head->; next = pfirst

p first-& gt; count = 1;

p first-& gt; menscore = 0;

p first-& gt; women score = 0;

p first-& gt; total score = 0;

}

Invalid save ()

{ FILE * fp

if((fp = fopen("school.dat "," wb"))==NULL)

{printf ("cannot open school.dat \ n");

fclose(FP);

Return;

}

fwrite(pfirst,sizeof(SCH), 10,FP);

fclose(FP);

Printf ("File saved successfully \ n");

}

Master ()

{

System ("CLS");

Printf(" \ n \ t \ t \ t tStatistics of sports meeting scores \ n ");

Printf ("Enter the number of schools (x>= 5):");

scanf("%d ",& ampNSC);

Printf ("Enter items of male players (X

scanf("%d ",& ampMSP);

Printf ("Entering women's events (

scanf("%d ",& ampwsp);

ntsp = MSP+wsp;

phead = calloc(ntsp,sizeof(int));

pafirst = phead

pasecond = phead

input();

Calculate ();

output();

save();

}