Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. string VilleAvecPlusLivres(int R2[NbRepondants], Repondant_s Repondants[NbRepondants])
  2. {
  3.     int NbrLivres[NbRepondants], TotalVille = 0, Position = 0, PlusGrand;
  4.     string ListeVille[NbRepondants];
  5.     bool Trouver;
  6.  
  7.     //Trouver le nombre de livre pour chaque ville
  8.     for (int i = 0; i < NbRepondants; i++)
  9.     {
  10.         Trouver = false;
  11.         for (int j = 0; j < TotalVille && !Trouver; j++)
  12.         {
  13.             if (Repondants[i].Ville == ListeVille[j])
  14.             {
  15.                 Trouver = true;
  16.                 NbrLivres[j] += R2[i];
  17.             }
  18.         }
  19.         if (!Trouver)
  20.         {
  21.             ListeVille[TotalVille] = Repondants[i].Ville;
  22.             NbrLivres[TotalVille] = R2[i];
  23.             TotalVille++;
  24.         }
  25.     }
  26.  
  27.     //Trouver le plus grand nombre de livres
  28.     PlusGrand = NbrLivres[0];
  29.     for (int i = 1; i < TotalVille; i++)
  30.     {
  31.         if (PlusGrand < NbrLivres[i])
  32.         {
  33.             PlusGrand = NbrLivres[i];
  34.             Position = i;
  35.         }
  36.     }
  37.  
  38.     return ListeVille[Position];
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement