Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Opgave3(){
- int a = 0, b = 0, x = 0, y = 0;
- //int iMaaned;
- int Specifikkeloeb[samlet_antalmaaneder][dage_pr_maaned];
- loebsdata motionsloeb[samlet_antalloeb];
- char Specifikloeber[samlet_antalmaaneder][dage_pr_maaned][specifikke_loebere][255];
- // Specifikkeloeb bliver tømt og er klar til at få indsat data
- int d;
- for (d = 0; d < samlet_antalmaaneder; d++){
- int c;
- for (c = 1; c < dage_pr_maaned; c++){
- Specifikkeloeb[d][c] = 0;
- }
- }
- // kører Laesdata for at kalde arrayet.
- Laesdata("runs.txt", motionsloeb);
- // looper aMotion-struct, og taeller antal loeb pr. dag,
- int i;
- for (i = 0; i < samlet_antalloeb; i++)
- {
- int check_for_maaned = 0;
- if (strcmp(motionsloeb[i].Maaned, "September") == 0)
- {
- check_for_maaned = 1;
- }
- int check_specifik_loeber = 0, e;
- for (e = 0; e < specifikke_loebere; e++)
- {
- // Hvis loeber er mødt før, på en dag skal personen ikke med igen
- if (strcmp(motionsloeb[i].Navn, Specifikloeber[check_for_maaned][motionsloeb[i].Dato][e]) == 0)
- {
- check_specifik_loeber = 1;
- break;
- }
- }
- if (check_specifik_loeber == 0)
- {
- int Unikkeloeb = Specifikkeloeb[check_for_maaned][motionsloeb[i].Dato];
- strcpy(Specifikloeber[check_for_maaned][motionsloeb[i].Dato][Unikkeloeb], motionsloeb[i].Navn);
- Specifikkeloeb[check_for_maaned][motionsloeb[i].Dato]++;
- }
- }
- // finder flest loeb i perioden
- int Maxloeb = 0, f = 0, g = 0;
- for (d = 0; d < samlet_antalmaaneder; d++)
- {
- int c;
- for (c = 1; c < dage_pr_maaned; c++)
- {
- if (Specifikkeloeb[d][c] > Maxloeb)
- {
- Maxloeb = Specifikkeloeb[d][c];
- f = d;
- g = c;
- }
- }
- }
- if (f = 0)
- printf("Den dato hvor der blev loebet flest unikke loeb var d. %d. August, hvor der i alt var %d loeb\n \n", g, Maxloeb);
- else
- printf("Den dato hvor der blev loebet flest unikke loeb var d. %d. September, hvor der i alt var %d loeb\n \n", g, Maxloeb);
- }
Add Comment
Please, Sign In to add comment