Guest User

Untitled

a guest
Apr 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.13 KB | None | 0 0
  1. void Opgave3(){
  2.  
  3.     int a = 0, b = 0, x = 0, y = 0;
  4.     //int iMaaned;
  5.     int Specifikkeloeb[samlet_antalmaaneder][dage_pr_maaned];
  6.     loebsdata motionsloeb[samlet_antalloeb];
  7.    
  8.     char Specifikloeber[samlet_antalmaaneder][dage_pr_maaned][specifikke_loebere][255];
  9.  
  10.     // Specifikkeloeb bliver tømt og er klar til at få indsat data
  11.     int d;
  12.     for (d = 0; d < samlet_antalmaaneder; d++){
  13.    
  14.                 int c;
  15.                 for (c = 1; c < dage_pr_maaned; c++){
  16.        
  17.                 Specifikkeloeb[d][c] = 0;
  18.             }
  19.     }
  20.  
  21.     // kører Laesdata for at kalde arrayet.
  22.     Laesdata("runs.txt", motionsloeb);
  23.    
  24.     // looper aMotion-struct, og taeller antal loeb pr. dag,
  25.    
  26.     int i;
  27.     for (i = 0; i < samlet_antalloeb; i++)
  28.     {
  29.         int check_for_maaned = 0;
  30.  
  31.         if (strcmp(motionsloeb[i].Maaned, "September") == 0)
  32.         {
  33.              check_for_maaned = 1;
  34.         }
  35.        
  36.          int check_specifik_loeber = 0, e;
  37.         for (e = 0; e < specifikke_loebere; e++)
  38.         {
  39.             // Hvis loeber er mødt før, på en dag skal personen ikke med igen
  40.             if (strcmp(motionsloeb[i].Navn, Specifikloeber[check_for_maaned][motionsloeb[i].Dato][e]) == 0)
  41.             {
  42.                 check_specifik_loeber = 1;
  43.                 break;
  44.             }
  45.         }
  46.  
  47.         if (check_specifik_loeber == 0)
  48.         {
  49.             int Unikkeloeb = Specifikkeloeb[check_for_maaned][motionsloeb[i].Dato];
  50.             strcpy(Specifikloeber[check_for_maaned][motionsloeb[i].Dato][Unikkeloeb], motionsloeb[i].Navn);
  51.             Specifikkeloeb[check_for_maaned][motionsloeb[i].Dato]++;
  52.         }
  53.     }          
  54.  
  55.     // finder flest loeb i perioden
  56.     int Maxloeb = 0, f = 0, g = 0;
  57.    
  58.     for (d = 0; d < samlet_antalmaaneder; d++)
  59.     {
  60.         int c;
  61.         for (c = 1; c < dage_pr_maaned; c++)
  62.         {
  63.             if (Specifikkeloeb[d][c] > Maxloeb)
  64.             {
  65.                 Maxloeb = Specifikkeloeb[d][c];
  66.                 f = d;
  67.                 g = c;
  68.             }
  69.         }
  70.     }
  71.  
  72.     if (f = 0)
  73.     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);
  74.     else
  75.     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);
  76.    
  77.    
  78. }
Add Comment
Please, Sign In to add comment