Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- typedef struct player
- {
- char name[100];
- char surname[100];
- char city[100];
- int yearOfBirth;
- int id;
- struct player *next;
- }PLAYER;
- typedef struct competition
- {
- int trying;
- double startTime;
- char name[100];
- int id;
- struct competition *next;
- }COMPETITION;
- typedef struct finale
- {
- struct player *player;
- struct competition *competition;
- double time[5];
- struct finale *next
- }FINALE;
- PLAYER *FindPlayer(PLAYER *pierwszy, int id)
- {
- PLAYER *current=pierwszy;
- while(current!=NULL)
- {
- if(current->id==id)
- {
- return current;
- }
- current=current->next;
- }
- }
- COMPETITION *FindCompetition(COMPETITION *pierwszy, int id)
- {
- COMPETITION *current=pierwszy;
- while(current!=NULL)
- {
- if(current->id==id)
- {
- return current;
- }
- current=current->next;
- }
- }
- PLAYER *CreatePlayer(char name[100], char surname[100], char city[100], int yearOfBirth, int id)
- {
- PLAYER *item=(PLAYER*)malloc(sizeof(PLAYER));
- item->yearOfBirth=yearOfBirth;
- item->id=id;
- strcpy(item->name,name);
- strcpy(item->surname,surname);
- strcpy(item->city,city);
- item->next=NULL;
- return item;
- }
- void AddPlayer(PLAYER ** pierwszy , char name[], char surname[], char city[], int yearOfBirth, int id)
- {
- PLAYER *item = CreatePlayer(name, surname, city, yearOfBirth, id);
- PLAYER *pom = *pierwszy;
- if(*pierwszy == NULL)
- {
- *pierwszy = item;
- }
- else
- {
- while(pom->next != NULL)
- {
- pom=pom->next;
- }
- pom->next = item;
- }
- }
- void printAllPlayers(PLAYER *pierwszy)
- {
- if(pierwszy==NULL)
- {
- printf("\nBrak informacji na temat zawodnikow.");
- }
- else
- {
- PLAYER *current=pierwszy;
- int i=0;
- while(current!=NULL)
- {
- i++;
- printf("\nid=%d imie=%s nazwisko=%s miasto=%s rok urodzenia=%d",current->id, current->name, current->surname, current->city, current->yearOfBirth);
- current=current->next;
- }
- }
- }
- COMPETITION *CreateCompetition(char name[100], int trying, double startTime, int id)
- {
- COMPETITION *item=(COMPETITION*)malloc(sizeof(COMPETITION));
- item->trying=trying;;
- strcpy(item->name,name);
- item->startTime=startTime;
- item->id=id;
- item->next=NULL;
- return item;
- }
- void AddCompetition(COMPETITION ** first, char name[100], int trying, double startTime, int id)
- {
- COMPETITION *item = CreateCompetition(name, trying, startTime, id);
- COMPETITION *pom = *first;
- if(*first == NULL)
- {
- *first = item;
- }
- else
- {
- while(pom->next != NULL)
- {
- pom=pom->next;
- }
- pom->next = item;
- }
- }
- void printAllCompetition(COMPETITION *first)
- {
- if(first==NULL)
- {
- printf("\nBrak informacji na temat konkurencji.");
- }
- else
- {
- COMPETITION *current=first;
- int i=0;
- while(current!=NULL)
- {
- i++;
- printf("\nid=%d\tnazwa=%s\tliczba prob=%d\tgodzina rozpoczecia=%.2lf",current->id, current->name, current->trying, current->startTime);
- current=current->next;
- }
- }
- }
- void FromFileToListPlayer(PLAYER **first)
- {
- FILE* file=fopen("Gracze.txt","r");
- if(file==NULL)
- {
- printf("\nNie udalo sie otworzyc pliku z informacjami o zawodnikach");
- }
- else
- {
- char table[100];
- int i, j=0;
- char NAME[100];
- for(i=0;i<100;i++)
- {
- NAME[i]=NULL;
- }
- char SURNAME[100];
- for(i=0;i<100;i++)
- {
- SURNAME[i]=NULL;
- }
- char YEAR[100];
- for(i=0;i<100;i++)
- {
- YEAR[i]=NULL;
- }
- char CITY[100];
- for(i=0;i<100;i++)
- {
- CITY[i]=NULL;
- }
- char ID[100];
- for(i=0;i<100;i++)
- {
- ID[i]=NULL;
- }
- int year, id;
- while(fscanf(file,"%s",table)!=EOF)
- {
- if (j==0)
- {
- strcpy(ID,table);
- id=atoi(ID);
- }
- else if(j==1)
- {
- strcpy(NAME,table);
- }
- else if(j==2)
- {
- strcpy(SURNAME,table);
- }
- else if(j==3)
- {
- strcpy(YEAR,table);
- year=atoi(YEAR);
- }
- else if(j==4)
- {
- strcpy(CITY,table);
- AddPlayer(first,NAME,SURNAME,CITY,year,id);
- }
- j++;
- if(j==5)
- {
- j=0;
- }
- }
- fclose(file);
- }
- }
- void FromFileToListCompetition(COMPETITION **first)
- {
- FILE* file2=fopen("Konkurencje.txt","r");
- if(file2==NULL)
- {
- printf("\nNie udalo sie otworzyc pliku z informacjami na temat konkurencji");
- }
- else
- {
- char table[100];
- int i, j=0;
- char NAME[100];
- for(i=0;i<100;i++)
- {
- NAME[i]=NULL;
- }
- char STARTTIME[100];
- for(i=0;i<100;i++)
- {
- STARTTIME[i]=NULL;
- }
- char TRYING[100];
- for(i=0;i<100;i++)
- {
- TRYING[i]=NULL;
- }
- char ID[100];
- for(i=0;i<100;i++)
- {
- ID[i]=NULL;
- }
- int trying,id;
- double startTime;
- while(fscanf(file2,"%s",table)!=EOF)
- {
- if(j==0)
- {
- strcpy(ID,table);
- id=atoi(ID);
- }
- else if(j==1)
- {
- strcpy(NAME,table);
- }
- else if(j==2)
- {
- strcpy(STARTTIME,table);
- sscanf(STARTTIME,"%lf",&startTime);
- }
- else if(j==3)
- {
- strcpy(TRYING,table);
- trying=atoi(TRYING);
- AddCompetition(first,NAME,trying,startTime,id);
- }
- j++;
- if(j==4)
- {
- j=0;
- }
- }
- fclose(file2);
- }
- }
- void FromFileToListFinale(FINALE **firstF, PLAYER **firstP, COMPETITION **firstC)
- {
- FILE* file3=fopen("Wyniki.txt","r");
- if(file3==NULL)
- {
- printf("\nNie udalo sie otworzyc pliku zawierajacego wyniki");
- }
- else
- {
- char table[10];
- int i, j=0,k=0,l=0;
- char IDOFPLAYER[10];
- for(i=0;i<10;i++)
- {
- IDOFPLAYER[i]=NULL;
- }
- char IDOFCOMPETITION[10];
- for(i=0;i<10;i++)
- {
- IDOFCOMPETITION[i]=NULL;
- }
- char TIME[10];
- for(i=0;i<10;i++)
- {
- TIME[i]=NULL;
- }
- int idp,idc;
- double time[5];
- for(i=0;i<5;i++)
- {
- time[i]=0;
- }
- while(fscanf(file3,"%s",table)!=EOF)
- {
- if(j==0)
- {
- strcpy(IDOFPLAYER,table);
- idp=atoi(IDOFPLAYER);
- j++;
- }
- else if(j==1)
- {
- strcpy(IDOFCOMPETITION,table);
- idc=atoi(IDOFCOMPETITION);
- j++;
- }
- else if(j==2)
- {
- if(idc==1)
- {
- sscanf(table,"%lf",&time[0]);
- if(time[0]!=0)
- {
- j++;
- k=1;
- }
- }
- else if(idc==2)
- {
- sscanf(table,"%lf",&time[l]);
- l++;
- if(time[1]!=0)
- {
- j++;
- k=1;
- }
- }
- else if(idc==3)
- {
- sscanf(table,"%lf",&time[l]);
- l++;
- if(time[2]!=0)
- {
- j++;
- k=1;
- }
- }
- else if(idc==4)
- {
- sscanf(table,"%lf",&time[l]);
- l++;
- if(time[3]!=0)
- {
- j++;
- k=1;
- }
- }
- else if(idc==5)
- {
- sscanf(table,"%lf",&time[l]);
- l++;
- if(time[4]!=0)
- {
- j++;
- k=1;
- }
- }
- }
- if(k==1)
- {
- AddFinale(firstF,firstP,firstC,time,idp,idc);
- l=0;
- k=0;
- for(i=0;i<5;i++)
- {
- time[i]=0;
- }
- }
- if(j==3)
- {
- j=0;
- }
- }
- fclose(file3);
- }
- }
- FINALE *CreateFinale(PLAYER **firstP, COMPETITION **firstC, double time[5], int idOfPlayer, int idOfCompetition)
- {
- FINALE *item=(FINALE*)malloc(sizeof(FINALE));
- item->player=FindPlayer(*firstP,idOfPlayer);
- item->competition=FindCompetition(*firstC,idOfCompetition);
- strcpy(item->time,time);
- item->next=NULL;
- return item;
- }
- void AddFinale(FINALE ** firstF,PLAYER **firstP, COMPETITION **firstC, double time[5], int idOfPlayer, int idOfCompetition)
- {
- FINALE *item = CreateFinale(firstP,firstC,time,idOfPlayer,idOfCompetition);
- FINALE *pom = *firstF;
- if(*firstF == NULL)
- {
- *firstF = item;
- }
- else
- {
- while(pom->next != NULL)
- {
- pom=pom->next;
- }
- pom->next = item;
- }
- }
- void printAllFinales(FINALE *first)
- {
- if(first==NULL)
- {
- printf("\nBrak informacji na temat wynikow.");
- }
- else
- {
- FINALE *current=first;
- int i=0;
- printf("\n");
- while(current!=NULL)
- {
- i++;
- if(current->competition->id==1)
- {
- printf("Id gracza -> %d Id Konkurencji -> %d Czas 1 -> %.2lfs\n", current->player->id, current->competition->id, current->time[0]);
- }
- if(current->competition->id==2)
- {
- printf("Id gracza -> %d Id Konkurencji -> %d Czas 1 -> %.2lfs Czas 2 -> %.2lfs\n", current->player->id, current->competition->id, current->time[0], current->time[1]);
- }
- if(current->competition->id==3)
- {
- printf("Id gracza -> %d Id Konkurencji -> %d Czas 1 -> %.2lfs Czas 2 -> %.2lfs Czas 3 -> %.2lfs\n", current->player->id, current->competition->id, current->time[0], current->time[1], current->time[2]);
- }
- if(current->competition->id==4)
- {
- printf("Id gracza -> %d Id Konkurencji -> %d Czas 1 -> %.2lfs Czas 2 -> %.2lfs Czas 3 -> %.2lfs Czas 4 -> %.2lfs\n", current->player->id, current->competition->id, current->time[0], current->time[1], current->time[2], current->time[3]);
- }
- if(current->competition->id==5)
- {
- printf("Id gracza -> %d Id Konkurencji -> %d Czas 1 -> %.2lfs Czas 2 -> %.2lfs Czas 3 -> %.2lfs Czas 4 -> %.2lfs Czas 5 -> %.2lfs\n", current->player->id, current->competition->id, current->time[0], current->time[1], current->time[2], current->time[3], current->time[4]);
- }
- current=current->next;
- }
- }
- }
- void A_ForEveryCompetitionPrintPlayersAndTheirAverageScore(FINALE *firstF,COMPETITION *firstC)
- {
- if((firstF==NULL) || (firstC==NULL))
- {
- printf("\nNie jest mozliwe wypisanie tego raportu, z powodu braku danych.");
- }
- else
- {
- printf("\n");
- FINALE *currentF=firstF;
- COMPETITION *currentC=firstC;
- FILE* fileA=fopen("a.txt","w");
- int i,j=0,numberOfPlayers=0;
- double suma=0,averageScore,sumaOfAverageScore=0,averageScoreOfAll;
- while(currentC!=NULL)
- {
- printf("Konkurencja %s Liczba prob=%d Godzina rozpoczecia %.2lf\n",currentC->name,currentC->trying,currentC->startTime);
- fprintf(fileA,"Konkurencja %s Liczba prob=%d Godzina rozpoczecia %.2lf\n",currentC->name,currentC->trying,currentC->startTime);
- while(currentF!=NULL)
- {
- if(currentC->id==currentF->competition->id)
- {
- printf("-> Imie i nazwisko: %s %s Miasto: %s Rok urodzenia %d\n",currentF->player->name, currentF->player->surname, currentF->player->city, currentF->player->yearOfBirth);
- fprintf(fileA,"-> Imie i nazwisko: %s %s Miasto: %s Rok urodzenia %d\n",currentF->player->name, currentF->player->surname, currentF->player->city, currentF->player->yearOfBirth);
- for(i=0;i<5;i++)
- {
- if(currentF->time[i]!=0)
- {
- suma=suma+currentF->time[i];
- j++;
- }
- }
- averageScore=suma/j;
- printf("\t Sredni czas-> %.2lfs\n", averageScore);
- fprintf(fileA,"\t Sredni czas-> %.2lfs\n", averageScore);
- suma=0;
- j=0;
- numberOfPlayers++;
- }
- sumaOfAverageScore=sumaOfAverageScore+averageScore;
- averageScore=0;
- currentF=currentF->next;
- }
- averageScoreOfAll=sumaOfAverageScore/numberOfPlayers;
- printf("Liczba graczy w konkurencji=%d, a ich sredni czas w konkurencji %s to %.2lf",numberOfPlayers,currentC->name, averageScoreOfAll);
- fprintf(fileA,"Liczba graczy w konkurencji=%d, a ich sredni czas w konkurencji %s to %.2lf",numberOfPlayers,currentC->name, averageScoreOfAll);
- sumaOfAverageScore=0;
- averageScoreOfAll=0;
- numberOfPlayers=0;
- currentF=firstF;
- currentC=currentC->next;
- printf("\n\n");
- fprintf(fileA,"\n\n");
- }
- fclose(fileA);
- printf("\n");
- }
- }
- void B_ForEveryPlayerPrintCompetitionAndHimAverageScoreInAllCompetitions(FINALE *firstF,PLAYER *firstP)
- {
- if((firstF==NULL) || (firstP==NULL))
- {
- printf("\nNie jest mozliwe wypisanie tego raportu, z powodu braku danych.");
- }
- else
- {
- printf("\n");
- FINALE *currentF=firstF;
- PLAYER *currentP=firstP;
- FILE* fileB=fopen("b.txt","w");
- int i,j=0;
- double suma=0,averageScore;
- while(currentP!=NULL)
- {
- printf("Imie i nazwisko: %s %s Miasto %s Rok urodzenia %d \n",currentP->name,currentP->surname,currentP->city,currentP->yearOfBirth);
- fprintf(fileB,"Imie i nazwisko: %s %s Miasto %s Rok urodzenia %d \n",currentP->name,currentP->surname,currentP->city,currentP->yearOfBirth);
- while(currentF!=NULL)
- {
- if(currentP->id==currentF->player->id)
- {
- printf("-> Konkurencja: %s Liczba prob=%d Godzina rozpoczecia %.2lf\n",currentF->competition->name, currentF->competition->trying, currentF->competition->startTime);
- fprintf(fileB,"-> Konkurencja: %s Liczba prob=%d Godzina rozpoczecia %.2lf\n",currentF->competition->name, currentF->competition->trying, currentF->competition->startTime);
- for(i=0;i<5;i++)
- {
- if(currentF->time[i]!=0)
- {
- suma=suma+currentF->time[i];
- j++;
- }
- }
- averageScore=suma/j;
- printf("\t Sredni czas-> %.2lfs\n", averageScore);
- fprintf(fileB,"\t Sredni czas-> %.2lfs\n", averageScore);
- suma=0;
- averageScore=0;
- j=0;
- }
- currentF=currentF->next;
- }
- currentF=firstF;
- currentP=currentP->next;
- printf("\n");
- fprintf(fileB,"\n");
- }
- fclose(fileB);
- printf("\n");
- }
- }
- void C_FindPlayerWhoStartedInTheHighestNumberOfCompetition(FINALE *firstF,PLAYER *firstP)
- {
- if((firstF==NULL) || (firstP)==NULL)
- {
- printf("\nNie jest mozliwe wypisanie tego raportu, z powodu braku danych.");
- }
- else
- {
- printf("\n");
- FINALE *currentF=firstF;
- PLAYER *currentP=firstP;
- FILE* fileC=fopen("c.txt","w");
- int tableOfPlayer[1000];
- int tableOfPlayer2[1000];
- int i,j,max=0;
- int who;
- for(i=0;i<1000;i++)
- {
- tableOfPlayer[i]=0;
- tableOfPlayer2[i]=0;
- }
- while(currentF!=NULL)
- {
- tableOfPlayer[currentF->player->id]++;
- currentF=currentF->next;
- }
- for(i=0;i<1000;i++)
- {
- //printf("Gracz id %d wynik %d\n",i, tableOfPlayer[i]);
- }
- for(i=0;i<1000;i++)
- {
- if(tableOfPlayer[i]>max)
- {
- max=tableOfPlayer[i];
- }
- }
- // printf("\n%d\n",max);
- j=0;
- for(i=0;i<1000;i++)
- {
- if(tableOfPlayer[i]==max)
- {
- //printf("id gracza %d\n", i);
- tableOfPlayer2[j]=i;
- j++;
- }
- }
- printf("Gracz ktory wzial udzial w najwiekszej ilosci konkurencji to\n");
- fprintf(fileC,"Gracz ktory wzial udzial w najwiekszej ilosci konkurencji to\n");
- for(i=0;i<1000;i++)
- {
- if(tableOfPlayer2[i]!=0)
- {
- //printf("Numer w tabeli %d ID %d", i, tableOfPlayer2[i]);
- currentP=FindPlayer(firstP,tableOfPlayer2[i]);
- printf("Imie:%s Nazwisko:%s Miasto:%s Rok Urodzenia=%d Liczba Konkurencji=%d\n", currentP->name,currentP->surname,currentP->city,currentP->yearOfBirth,max);
- fprintf(fileC,"Imie:%s Nazwisko:%s Miasto:%s Rok Urodzenia=%d Liczba Konkurencji=%d\n", currentP->name,currentP->surname,currentP->city,currentP->yearOfBirth,max);
- }
- }
- fclose(fileC);
- printf("\n");
- }
- }
- void D_ForGivenPlayerPrintTheBestScoreInAllCompetitions(FINALE *firstF, PLAYER *firstP, int idOfPlayer)
- {
- if((firstF==NULL) || (firstP)==NULL)
- {
- printf("\nNie jest mozliwe wypisanie tego raportu, z powodu braku danych.");
- }
- else
- {
- printf("\n");
- FINALE *currentF=firstF;
- PLAYER *currentP=firstP;
- FILE* fileD=fopen("d.txt","w");
- currentP=FindPlayer(firstP,idOfPlayer);
- printf("Imie i nazwisko %s %s Miasto %s Rok urodzenia %d\n", currentP->name,currentP->surname,currentP->city,currentP->yearOfBirth);
- fprintf(fileD,"Imie i nazwisko %s %s Miasto %s Rok urodzenia %d\n", currentP->name,currentP->surname,currentP->city,currentP->yearOfBirth);
- double min=999999;
- int i;
- while(currentF!=NULL)
- {
- if(currentF->player->id==idOfPlayer)
- {
- if(currentF->competition->id==1)
- {
- for(i=0;i<1;i++)
- {
- if(currentF->time[i]<min)
- {
- min=currentF->time[i];
- }
- }
- }
- else if(currentF->competition->id==2)
- {
- for(i=0;i<2;i++)
- {
- if(currentF->time[i]<min)
- {
- min=currentF->time[i];
- }
- }
- }
- else if(currentF->competition->id==3)
- {
- for(i=0;i<3;i++)
- {
- if(currentF->time[i]<min)
- {
- min=currentF->time[i];
- }
- }
- }
- else if(currentF->competition->id==4)
- {
- for(i=0;i<4;i++)
- {
- if(currentF->time[i]<min)
- {
- min=currentF->time[i];
- }
- }
- }
- else if(currentF->competition->id==5)
- {
- for(i=0;i<5;i++)
- {
- if(currentF->time[i]<min)
- {
- min=currentF->time[i];
- }
- }
- }
- printf("->Najlepszy czas w konkurencji %s %.2lfs\n",currentF->competition->name, min);
- fprintf(fileD,"->Najlepszy czas w konkurencji %s %.2lfs\n",currentF->competition->name, min);
- min=999999;
- }
- currentF=currentF->next;
- }
- fclose(fileD);
- printf("\n");
- }
- }
- void E_CalculateHowManyCompetitionsForEveryPlayer(FINALE *firstF,PLAYER *firstP)
- {
- if((firstF==NULL) || (firstP)==NULL)
- {
- printf("\nNie jest mozliwe wypisanie tego raportu, z powodu braku danych.");
- }
- else
- {
- printf("\n");
- PLAYER *currentP=firstP;
- FINALE *currentF=firstF;
- FILE *fileE=fopen("e.txt","w");
- int howManyCompetition=0;
- int howManyPlayers=0;
- double score;
- while(currentP!=NULL)
- {
- howManyPlayers++;
- currentP=currentP->next;
- }
- while(currentF!=NULL)
- {
- howManyCompetition++;
- currentF=currentF->next;
- }
- score=(double)howManyCompetition/(double)howManyPlayers;
- printf("W zawodach wzielo udzial %d graczy, laczna liczba startow w konkurencjach to %d.\nSrednio przypadlo %.2lf startu na zawodnika.\n", howManyPlayers, howManyCompetition, score);
- fprintf(fileE,"W zawodach wzielo udzial %d graczy, laczna liczba startow w konkurencjach to %d.\nSrednio przypadlo %.2lf startu na zawodnika.\n", howManyPlayers, howManyCompetition, score);
- fclose(fileE);
- printf("\n");
- }
- }
- void F_ForEveryPlayerFindCompetitionInWhichWasFiveTryingAndDifferenceBetweenTheWorstScoreAndTheBestScoreWasLowerThanGivenValue(FINALE *firstF,PLAYER *firstP,double value)
- {
- if((firstF==NULL) || (firstP)==NULL)
- {
- printf("\nNie jest mozliwe wypisanie tego raportu, z powodu braku danych.");
- }
- else
- {
- printf("\n");
- FINALE *currentF=firstF;
- PLAYER *currentP=firstP;
- FILE *fileF=fopen("f.txt","w");
- double max=0,min=999999;
- int i;
- printf("Zawodnicy, ktorzy wzieli udzial w konkurencjach, w ktorych bylo 5 prob:\n");
- fprintf(fileF,"Zawodnicy, ktorzy wzieli udzial w konkurencjach, w ktorych bylo 5 prob:\n");
- while(currentP!=NULL)
- {
- while(currentF!=NULL)
- {
- if(currentF->competition->trying==5)
- {
- for(i=0;i<5;i++)
- {
- if(currentF->time[i]<min)
- {
- min=currentF->time[i];
- }
- }
- for(i=0;i<5;i++)
- {
- if(currentF->time[i]>max)
- {
- max=currentF->time[i];
- }
- }
- printf("-> %s %s ( %s ), jego najlepszy czas to %.2lf, a najgorszy to %.2lf",currentF->player->name, currentF->player->surname,currentF->competition->name,min,max);
- fprintf(fileF,"-> %s %s ( %s ), jego najlepszy czas to %.2lf, a najgorszy to %.2lf",currentF->player->name, currentF->player->surname,currentF->competition->name,min,max);
- if(max-min<value)
- {
- printf(" - Roznica miedzy czasem najlepszym a najgorszym jest mniejsza od zadanej wartosci (%.2lf)\n",value);
- fprintf(fileF," - Roznica miedzy czasem najlepszym a najgorszym jest mniejsza od zadanej wartosci (%.2lf)\n",value);
- }
- else
- {
- printf("\n");
- fprintf(fileF,"\n");
- }
- max=0,min=999999;
- }
- currentF=currentF->next;
- }
- currentP=currentP->next;
- }
- currentF=firstF;
- currentP=firstP;
- while(currentP!=NULL)
- {
- while(currentF!=NULL)
- {
- currentF=currentF->next;
- }
- currentP=currentP->next;
- }
- fclose(fileF);
- }
- }
- void Menu(FINALE *firstF,PLAYER *firstP,COMPETITION *firstC)
- {
- char x;
- int who;
- double value;
- printf("Wybierz raport z zawodow KOSTKA RUBIKA, ktory chcesz wykonac?\n");
- printf("A -> Dla kazdej konkurencji wypisze liste zawodnikow i ich sredni wynik.\n");
- printf("B -> Dla kazdego zawodnika wypisz wszystkie konkurencje i jego sredni wynik w kazdej konkurencji.\n");
- printf("C -> Znajdz zawodnika/ow, ktory/rzy wzial/eli udzial w najwiekszej liczbie konkurencji.\n");
- printf("D -> Dla podanego zawodnika wypisz wynik najlepszej proby (najmniejszy czas) w kazdej konkurencji.\n");
- printf("E -> Oblicz, ile srednio konkurencji przypadlo na kazdego zawodnika.\n");
- printf("F -> Dla kazdego zawodnika znajdz konkurencje, w ktorych bylo 5 prob, a roznica miedzy najgorsza, a najlepsza proba byla mniejsza od zadanej wartosci.\n");
- printf("G -> Wypisz 3 listy, zawodnikow, konkurencji oraz wynikow.\n");
- printf("H -> Wykonaj wszystkie raporty od A do F.\n");
- scanf("%c",&x);
- switch (x)
- {
- case 'A': A_ForEveryCompetitionPrintPlayersAndTheirAverageScore(firstF,firstC);
- Action(firstF,firstP,firstC);
- break;
- case 'B': B_ForEveryPlayerPrintCompetitionAndHimAverageScoreInAllCompetitions(firstF,firstP);
- Action(firstF,firstP,firstC);
- break;
- case 'C': C_FindPlayerWhoStartedInTheHighestNumberOfCompetition(firstF,firstP);
- Action(firstF,firstP,firstC);
- break;
- case 'D':
- printf("\nDla ktorego? Podaj ID zawodnika ");
- scanf("%d", &who);
- D_ForGivenPlayerPrintTheBestScoreInAllCompetitions(firstF,firstP,who);
- Action(firstF,firstP,firstC);
- break;
- case 'E': E_CalculateHowManyCompetitionsForEveryPlayer(firstF,firstP);
- Action(firstF,firstP,firstC);
- break;
- case 'F':
- printf("\nPodaj wartosc roznicy miedzy najgorsza a najlepsza proba ");
- scanf("%lf", &value);
- F_ForEveryPlayerFindCompetitionInWhichWasFiveTryingAndDifferenceBetweenTheWorstScoreAndTheBestScoreWasLowerThanGivenValue(firstF,firstP,value);
- Action(firstF,firstP,firstC);
- break;
- case 'G':
- printAllPlayers(firstP);
- printAllCompetition(firstC);
- printAllFinales(firstF);
- Action(firstF,firstP,firstC);
- break;
- case 'H':
- printf("\t\tRAPORT A:\n");
- A_ForEveryCompetitionPrintPlayersAndTheirAverageScore(firstF,firstC);
- printf("\t\tRAPORT B:\n");
- B_ForEveryPlayerPrintCompetitionAndHimAverageScoreInAllCompetitions(firstF,firstP);
- printf("\t\tRAPORT C:\n");
- C_FindPlayerWhoStartedInTheHighestNumberOfCompetition(firstF,firstP);
- printf("\t\tRAPORT D:\n");
- printf("\nDla ktorego? Podaj ID zawodnika ");
- scanf("%d", &who);
- D_ForGivenPlayerPrintTheBestScoreInAllCompetitions(firstF,firstP,who);
- printf("\t\tRAPORT E:\n");
- E_CalculateHowManyCompetitionsForEveryPlayer(firstF,firstP);
- printf("\t\tRAPORT F:\n");
- printf("\nPodaj wartosc roznicy miedzy najgorsza a najlepsza proba ");
- scanf("%lf", &value);
- F_ForEveryPlayerFindCompetitionInWhichWasFiveTryingAndDifferenceBetweenTheWorstScoreAndTheBestScoreWasLowerThanGivenValue(firstF,firstP,value);
- Action(firstF,firstP,firstC);
- break;
- default:
- system("cls");
- Menu(firstF,firstP,firstC);
- }
- }
- void Action(FINALE *firstF,PLAYER *firstP,COMPETITION *firstC)
- {
- char action[3];
- printf("\nCo dalej? Aby wylaczyc program wpisz END, aby kontynuowac wpisz cokolwiek: \n");
- scanf("%s",action);
- if((action[0]==69) && (action[1]==78) && (action[2]==68))
- {
- exit(0);
- }
- else
- {
- system("cls");
- Menu(firstF,firstP,firstC);
- }
- }
- int main()
- {
- PLAYER *firstP=NULL;
- COMPETITION *firstC=NULL;
- FINALE *firstF=NULL;
- FromFileToListPlayer(&firstP);
- FromFileToListCompetition(&firstC);
- FromFileToListFinale(&firstF,&firstP,&firstC);
- Menu(firstF,firstP,firstC);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement