IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Pascal Discussion :

Programme Ligue des champions


Sujet :

Pascal

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut Programme Ligue des champions
    bonjour, j'ai un projet à faire en informatique en turbo pascal.
    le but est de recréer la ligue des champions (1er tour preliminaire, 2e tour préliminaire, 3e tour), et je ne sais pas comment faire pour créer les 8 poules de 4 équipes pour les 8e de finale.

    en gros, j'ai 16 equipes issues du troisième tour, et 16 autres qui arrivent dans la competition.
    comment faire pour créer 8 poules aleatoirement avec ses 32 équipes.

    si vous pouvez m'aidez, ou si vous avez besoin des sources du programme je vous les passe.

    PS:je suis en ecole d'ingé dans le BTP et l'informatique n'est pas ma grande passion.

    merci

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    au fait le score importe peu. soit l'equipe gagne soit elle perd

  3. #3
    Expert confirmé

    Inscrit en
    Août 2006
    Messages
    3 942
    Détails du profil
    Informations forums :
    Inscription : Août 2006
    Messages : 3 942
    Points : 5 654
    Points
    5 654
    Par défaut
    Fio,
    Citation Envoyé par jbggg
    au fait le score importe peu. soit l'equipe gagne soit elle perd
    Et soit on te fait ton code et tu gagnes, soit on ne le fait pas et tu perds ?

    Sans blague. Nous sommes sur un forum d'entraide, ça ne signifie pas que nous sommes là pour faire TON travail.

    Montre-nous où tu en es, et on pourra t'aider pour les points où tu coinces.
    Si les cons volaient, il ferait nuit à midi.

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    non mais sans me le faire
    mais je ne sais pas si mon idée pour partir est bonne

    en fait pour les autres tour, j'ai fait des tableaux

    mais pour les 8eme comment faire pour créer les poules aleatoirement en eliminant les équipes deja prises.

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    voici les codes.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    program ligue;
    uses crt;
    var qualif1,elimine1:array[1..12] of string;
    var qualif2,elimine2:array[1..14] of string;
    var qualif3,elimine3:array[1..16] of string;
     
    {fonction pour avantager liverpool au 1er et 2Šme tour}
    function match(A,B:string):string;
    var p,q:integer;
    begin
    randomize;
    p:=random(2);
    q:=random(4);
    if (A<>'  ENG    Liverpool FC')and(B<>'  ENG    Liverpool FC')
    then
       begin
       if p=1 then match:=A else match:=B
       end else
         begin
         if p<=q then match:='  ENG    Liverpool FC' else
            begin
            if A='  ENG    Liverpool FC' then match:=B else match:=A;
            end;
         end;
       end;
     
     
     
     
    {fonction pour ne plus avantager personne au tour 3 et au phase finale}
    function match2(C,D:string):string;
    var h:integer;
     
     
       begin
    randomize;
    h:=random(2);
    if h=1 then match2:=C else match2:=D
       end;
     
     
     
     
     
    {---------------------------procedure tour 1 ----------------------------------}
     
    procedure tour1;
    const c=24;
    var tabi, tabf:array[1..c] of string;
     
     
    var i,j,k,l,n,p,q,s:integer;
     
     
    begin
    clrscr;
    randomize;
    tabi[1]:= '  SVK    MFK Ruzomberok';
    tabi[2]:= '  SLO    NK Gorica';
    tabi[3]:= '  CYP    Apollon Limassol FC';
    tabi[4]:= '  BIH    NK Široki Brijeg';
    tabi[5]:= '  LAT    FHK Liepajas Metalurgs';
    tabi[6]:= '  FIN    Myllykosken Pallo-47';
    tabi[7]:= '  MOL    FC Sheriff';
    tabi[8]:= '  GEO    FC Sioni Bolnisi';
    tabi[9]:= '  LIT    FK Ekranas';
    tabi[10]:= '  ISL    FH Hafnarfjördur';
    tabi[11]:= '  MKD    FK Rabotnicki';
    tabi[12]:= '  IRL    Cork City FC';
    tabi[13]:= '  BLS    FC Shakhtyor Soligorsk';
    tabi[14]:= '  ARM    FC Pyunik';
    tabi[15]:= '  MLT    Birkirkara FC';
    tabi[16]:= '  ALB    KS Elbasani';
    tabi[17]:= '  EST    FC TVMK Tallinn';
    tabi[18]:= '  NIR    Linfield FC';
    tabi[19]:= '  WAL    The New Saints FC';
    tabi[20]:= '  LUX    F91 Dudelange';
    tabi[21]:= '  AZE    FK Baku';
    tabi[22]:= '  FAR    B36 Tórshavn';
    tabi[23]:= '  KAZ    FK Aktobe';
    tabi[24]:= '  ENG    Liverpool FC';
     
    for j:=1 to c do
      begin
      n:=random(c+1-j)+1;
      tabf[c-j+1]:=tabi[n];
      for k:=n to c-j do tabf[k]:=tabi[k+1];
      for p:=1 to n-1 do tabf[p]:=tabi[p];
      for q:=1 to c   do tabf[q]:=tabf[q];
      end;
     
    clrscr;
    gotoXY(5,1);
    writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
    gotoXY(5,2);
    writeln('º                                                                        º');
    gotoXY(5,3);
    writeln('ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹');
    gotoXY(5,4);
    writeln('º                                                                        º');
    gotoXY(5,5);
    writeln('ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹');
    gotoXY(39,2);
    writeln('Premier tour');
    gotoXY(17,4);
    writeln('Qualifi‚s                  º ');
    gotoXY(58,4);
    writeln('Elimin‚s');
    for s:=0 to 11 do
      begin
      qualif1[s+1]:=match(tabi[2*s+1],tabi[2*s+2]);
      if qualif1[s+1]=tabi[2*s+1]
      then elimine1[s+1]:=tabi[2*s+2]
      else elimine1[s+1]:=tabi[2*s+1];
       gotoXY(5,6+s);
       writeln('º                                      º                                 º');
       gotoXY(10,6+s);
       writeln(qualif1[s+1]);
       gotoXY(47,6+s);
       writeln(elimine1[s+1]);
       end;
     
       gotoXY(5,18);
       writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
       readln;
      end;
     
    {-------------------------------------procedure tour2 --------------------------------}
    procedure tour2;
    const c=28;
    var tabi,tabf:array[1..c] of string;
    var i,j,k,l,n,p,q,s,t:integer;
     
    begin
    clrscr;
     
     
    randomize;
    for t:=1 to 12 do tabi[t]:=qualif1[t];
     
    tabi[13]:='  SCO  Heart of Midlothian FC';
    tabi[14]:='  TUR  Fenerbahçe SK';
    tabi[15]:='  CZE  FK Mladá Boleslav';
    tabi[16]:='  RUS  FC Spartak Moskva';
    tabi[17]:='  AUT  SV Austria Salzburg';
    tabi[18]:='  UKR  FC Dynamo Kyiv';
    tabi[19]:='  SCG  FK Crvena Zvezda';
    tabi[20]:='  POL  Legia Warszawa ';
    tabi[21]:='  SUI  FC Zurich';
    tabi[22]:='  NOR  Vålerenga IF';
    tabi[23]:='  BUL  PFC Levski Sofia';
    tabi[24]:='  CRO  NK Dinamo Zagreb';
    tabi[25]:='  DEN  FC Kobenhavn';
    tabi[26]:='  HUN  Debreceni VSC';
    tabi[27]:='  ROU  FC Steaua Bucuresti';
    tabi[28]:='  SWE  Djurgardens IF';
     
     
    for j:=1 to c do
      begin
      n:=random(c+1-j)+1;
      tabf[c-j+1]:=tabi[n];
      for k:=n to c-j do tabf[k]:=tabi[k+1];
      for p:=1 to n-1 do tabf[p]:=tabi[p];
      for q:=1 to c   do tabf[q]:=tabf[q];
      end;
     
    clrscr;
    gotoXY(5,1);
    writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
    gotoXY(5,2);
    writeln('º                                                                        º');
    gotoXY(5,3);
    writeln('ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹');
    gotoXY(5,4);
    writeln('º                                                                        º');
    gotoXY(5,5);
    writeln('ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹');
    gotoXY(39,2);
    writeln('DeuxiŠme tour');
    gotoXY(17,4);
    writeln('Qualifi‚s                  º ');
    gotoXY(58,4);
    writeln('Elimin‚s');
    for s:=0 to 13 do
      begin
      qualif2[s+1]:=match(tabi[2*s+1],tabi[2*s+2]);
      if qualif2[s+1]=tabi[2*s+1]
      then elimine2[s+1]:=tabi[2*s+2]
      else elimine2[s+1]:=tabi[2*s+1];
       gotoXY(5,6+s);
       writeln('º                                      º                                 º');
       gotoXY(10,6+s);
       writeln(qualif2[s+1]);
       gotoXY(47,6+s);
     
       writeln(elimine2[s+1]);
       end;
     
       gotoXY(5,20);
       writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
      readln;
      end;
     
    {-------------------------------------- tour3 -----------------------------------}
     
    procedure tour3;
    const c=32;
    var tabi,tabf:array[1..c] of string;
    var i,j,k,l,n,p,q,s,t,u:integer;
     
    begin
    clrscr;
     
     
    randomize;
    for u:=1 to 14 do tabi[u]:=qualif2[u];
     
    tabi[15]:=' ESP  Valencia CF';
    tabi[16]:=' ESP  CA Osasuna';
    tabi[17]:=' ENG  Arsenal FC';
    tabi[18]:=' ENG  Everton';
    tabi[19]:=' ITA  AC Milan';
    tabi[20]:=' ITA  AC Chievo Verona';
    tabi[21]:=' FRA  LOSC Lille Métropole';
    tabi[22]:=' GER  Hamburger SV';
    tabi[23]:=' POR  SL Benfica';
    tabi[24]:=' NED  AFC Ajax';
    tabi[25]:=' GRE  AEK Athens FC';
    tabi[26]:=' BEL  R. Standard de Liège';
    tabi[27]:=' TUR  Galatasaray SK';
    tabi[28]:=' CZE  FC Slovan Liberec';
    tabi[29]:=' RUS  PFC CSKA Moskva';
    tabi[30]:=' AUT  FK Austria Wien';
    tabi[31]:=' UKR  FC Shakhtar Donetsk';
    tabi[32]:=' ISR  Maccabi Haifa FC';
     
     
    for j:=1 to c do
      begin
      n:=random(c+1-j)+1;
      tabf[c-j+1]:=tabi[n];
      for k:=n to c-j do tabf[k]:=tabi[k+1];
      for p:=1 to n-1 do tabf[p]:=tabi[p];
      for q:=1 to c   do tabf[q]:=tabf[q];
      end;
     
    clrscr;
    gotoXY(5,1);
    writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
    gotoXY(5,2);
    writeln('º                                                                        º');
    gotoXY(5,3);
    writeln('ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹');
    gotoXY(5,4);
    writeln('º                                                                        º');
    gotoXY(5,5);
    writeln('ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹');
    gotoXY(39,2);
    writeln('TroisiŠme tour');
    gotoXY(17,4);
    writeln('Qualifi‚s                  º ');
    gotoXY(58,4);
    writeln('Elimin‚s');
    for s:=0 to 15 do
      begin
      qualif3[s+1]:=match2(tabi[2*s+1],tabi[2*s+2]);
      if qualif3[s+1]=tabi[2*s+1]
      then elimine3[s+1]:=tabi[2*s+2]
      else elimine3[s+1]:=tabi[2*s+1];
       gotoXY(5,6+s);
       writeln('º                                      º                                 º');
       gotoXY(10,6+s);
       writeln(qualif3[s+1]);
       gotoXY(47,6+s);
     
       writeln(elimine3[s+1]);
       end;
     
       gotoXY(5,22);
       writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
      readln;
      end;
     
    {--------------------------------------- 8e finale -------------------------------}
    procedure 8finale;
    const c=32;
    var tabi, tabf:array[1..c] of string;
     
    var i,j,k,l,n,p,q,s:integer;
     
    begin
     clrscr;
     
     randomize;
     for v:=1 to 16 do tabi[v]:=qualif3[v];
     
     tabi[17]:='
     
     
     
    begin
    tour1;
    tour2;
    tour3;
    readln;
    end.

  6. #6
    Expert confirmé

    Inscrit en
    Août 2006
    Messages
    3 942
    Détails du profil
    Informations forums :
    Inscription : Août 2006
    Messages : 3 942
    Points : 5 654
    Points
    5 654
    Par défaut
    Sae,

    Aïe, Aïe, Aïe.

    Il faut mettre ton code en forme, c'est à dire :
    - faire une indentation cohérente et régulière
    - mettre des sauts de ligne pour aérer, sans éprouver le besoin d'en mettre plusieurs à la suite
    - mettre des commentaires utiles, car ce genre de truc :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    {---------------------------procedure tour 1 ----------------------------------}
    juste avant
    ne sert absolument à rien.

    Et tant qu'à faire, montrer un programme qui compile.

    Je n'ai pas testé la compilation, mais quand je vois
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    var i,j,k,l,n,p,q,s:integer;
     
    begin
     clrscr;
     
     randomize;
     for v:=1 to 16 do tabi[v]:=qualif3[v];
     
     tabi[17]:='
     
     
     
    begin
    tour1;
    tour2;
    tour3;
    readln;
    end.
    je sais que ça ne va pas compiler, n'est-ce pas ?

    En lisant très rapidement, j'ai vu que tu utilises randomize un peu partout.
    Une règle est de ne l'utiliser qu'une fois dans un programme, ce que l'on fait en général au début du programme principal.
    Si les cons volaient, il ferait nuit à midi.

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    si si ca compile très bien

    merci pour la mise en page.

    la finb ne fonctionne pas ce qui est normale car j'ai juste commencer le debut de ma procedure 8e de finale

  8. #8
    Expert confirmé

    Inscrit en
    Août 2006
    Messages
    3 942
    Détails du profil
    Informations forums :
    Inscription : Août 2006
    Messages : 3 942
    Points : 5 654
    Points
    5 654
    Par défaut
    Hoi,
    Citation Envoyé par jbggg
    si si ca compile très bien
    Alors le code posté n'est pas celui que tu compiles.
    Si les cons volaient, il ferait nuit à midi.

  9. #9
    Expert confirmé
    Avatar de Loceka
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    2 276
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 2 276
    Points : 4 845
    Points
    4 845
    Par défaut
    Pour l'idée de base qui est d'utiliser des tableaux ça me semble correct. A vrai dire je ne vois pas trop comment procéder autrement.

    Par contre il y'a des passages que je ne comprends pas trop dans ton code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    const c=24;
    for j:=1 to c do
      begin
      n:=random(c+1-j)+1;
      tabf[c-j+1]:=tabi[n];
      for k:=n to c-j do tabf[k]:=tabi[k+1];
      for p:=1 to n-1 do tabf[p]:=tabi[p];
      for q:=1 to c   do tabf[q]:=tabf[q]; // cette ligne est inutile ET elle "écrase" les valeurs précédentes !
      end;
    Par contre pour ce qui est de la façon de faire il est possible de l'améliorer.
    C'est du détail à vrai dire si tu ne continues pas du tout dans l'informatique mais disons que ça choque.
    • utiliser des noms de variables/constantes plus explicites
    • définir plus de constantes (déjà les bornes des tableaux et les noms des équipes)
    • écrire les procédures en passant les tableaux en paramètre
    • réutiliser les mêmes tableaux d'une procédure à l'autre (inutile d'en recréer à chaque fois)
    • commenter le code (en fait c'est pas forcément plus important que les autres points mais le correcteur en tiendra compte)
    • n'appeller qu'un seul randomize en début de ton programme principal (begin ... end.)


    C'est tout ce que je vois pour l'instant.

    Enfin juste une réécriture de ta fonction 'match' pour la rendre plus "jolie" :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    { ta fonction (il manque un "end" soit dit en passant) }
    function match(A,B:string):string;
    var p,q:integer;
    begin
    randomize;
    p:=random(2);
    q:=random(4);
    if (A<>'  ENG    Liverpool FC')and(B<>'  ENG    Liverpool FC')
    then
       begin
       if p=1 then match:=A else match:=B
       end else
         begin
         if p<=q then match:='  ENG    Liverpool FC' else
            begin
            if A='  ENG    Liverpool FC' then match:=B else match:=A;
            end;
         end;
       end;
     
    { la fonction réécrite (en tenant compte des remarques que j'ai faite plus haut) }
    const liverpool := '  ENG    Liverpool FC';
    // ...
    function match(A,B:string):string;
    var
      p,q : integer;
    begin
    p:=random(2);
    if (A = liverpool) or (B = liverpool) then
      begin
      q:=random(4);
      if p<=q then
        match:= liverpool
      else
        if (A = liverpool) then
          match:=B
        else
          match:=A;
      end
    else
      if p=1 then
        match:=A
      else
        match:=B;
    end;
    Edit :
    petite précision : un nom de fonction/procédure ne doit pas commencer par un entier ! (si mes souvenirs sont bons)

  10. #10
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    Citation Envoyé par Loceka
    Pour l'idée de base qui est d'utiliser des tableaux ça me semble correct. A vrai dire je ne vois pas trop comment procéder autrement.

    Par contre il y'a des passages que je ne comprends pas trop dans ton code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    const c=24;
    for j:=1 to c do
      begin
      n:=random(c+1-j)+1;
      tabf[c-j+1]:=tabi[n];
      for k:=n to c-j do tabf[k]:=tabi[k+1];
      for p:=1 to n-1 do tabf[p]:=tabi[p];
      for q:=1 to c   do tabf[q]:=tabf[q]; // cette ligne est inutile ET elle "écrase" les valeurs précédentes !
      end;
    moi non plus je ne comprend pas cette ligne. c'est le prof qui nous a fait ce truc. j'essaye de comprendre mais je ne vois vraiment pas à quoi correspond le (c+1-j)

  11. #11
    Expert confirmé
    Avatar de Loceka
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    2 276
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 2 276
    Points : 4 845
    Points
    4 845
    Par défaut
    Les profs n'ont pas toujours raison.

    Apparement tu t'es plutôt bien débrouillé par ailleurs alors essaye d'écrire un code qui fait ce que tu veux tout en le comprenant (vire cette boucle et réécrit ton code pour qu'il fasse quand même ce que tu veux).

  12. #12
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    en fait je crois qu'il y a pas mal de chose que je ne comprend pas.

    la partie:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    for s:=0 to 11 do
      begin
      qualif1[s+1]:=match(tabi[2*s+1],tabi[2*s+2]);
      if qualif1[s+1]=tabi[2*s+1]
      then elimine1[s+1]:=tabi[2*s+2]
      else elimine1[s+1]:=tabi[2*s+1];
       gotoXY(5,6+s);
       writeln('º                                      º                                 º');
       gotoXY(10,6+s);
       writeln(qualif1[s+1]);
       gotoXY(47,6+s);
       writeln(elimine1[s+1]);
       end;
    à quoi correspond le "s"??? c'est une variable mais je ne comprend pas à quoi elle correspond.

  13. #13
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    bon je crois avoir compris la signification de la variable "s".
    je pense que c'est le nombre de ligne de mes tableau non??

    pour se qui concerne les seizieme de finale j'ai trouver , mais j'ai un petit probleme. les equipes des poules ne changent pas.(je ne sais pa si c'est trè compréhensible).
    en gros j'ai toujour les 4 meme equipe dans la poule1, les 4 meme dans la poule2 etc. alors que je voudrais que ce soit aléatoire.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    program seizieme;
    uses crt;
    var qualifP1,elimineP1:array[1..2] of string;
    var qualifP2,elimineP2:array[1..2] of string;
     
    function match2(C,D:string):string;
    var h:integer;
       begin
    randomize;
    h:=random(2);
    if h=1 then match2:=C else match2:=D
       end;
     
     
       const c=24;
    var tabi, tabf:array[1..c] of string;
     
     
    var i,j,k,l,n,p,q,s:integer;
     
     
    begin
    clrscr;
    randomize;
    tabi[1]:= '  SVK    MFK Ruzomberok';
    tabi[2]:= '  SLO    NK Gorica';
    tabi[3]:= '  CYP    Apollon Limassol FC';
    tabi[4]:= '  BIH    NK Široki Brijeg';
    tabi[5]:= '  LAT    FHK Liepajas Metalurgs';
    tabi[6]:= '  FIN    Myllykosken Pallo-47';
    tabi[7]:= '  MOL    FC Sheriff';
    tabi[8]:= '  GEO    FC Sioni Bolnisi';
     
    for j:=1 to c do
      begin
      n:=random(c+1-j)+1;
      tabf[c-j+1]:=tabi[n];
      for k:=n to c-j do tabf[k]:=tabi[k+1];
      for p:=1 to n-1 do tabf[p]:=tabi[p];
      for q:=1 to c   do tabf[q]:=tabf[q];
      end;
     
    for s:=0 to 1 do
      begin
      qualifP1[s+1]:=match2(tabi[2*s+1],tabi[2*s+2]);
      if qualifP1[s+1]=tabi[2*s+1]
      then elimineP1[s+1]:=tabi[2*s+2]
      else elimineP1[s+1]:=tabi[2*s+1];
     
      gotoXY(5,1);
      writeln('poule 1');
      gotoXY(1,2);
      writeln('qualifi‚s');
      gotoXY(15,2);
      writeln('elimin‚s');
      gotoXY(1,4+s);
      writeln(qualifP1[s+1]);
      gotoXY(15,4+s);
      writeln(elimineP1[s+1]);
      end;
     
    for s:=0 to 1 do
      begin
      qualifP2[s+5]:=match2(tabi[2*s+5],tabi[2*s+6]);
      if qualifP2[s+5]=tabi[2*s+5]
      then elimineP2[s+5]:=tabi[2*s+6]
      else elimineP2[s+5]:=tabi[2*s+5];
     
      gotoXY(5,15);
      writeln('poule 2');
      gotoXY(1,16);
      writeln('qualifi‚s');
      gotoXY(15,16);
      writeln('elimin‚s');
      gotoXY(1,18+s);
      writeln(qualifP2[s+5]);
      gotoXY(15,18+s);
      writeln(elimineP2[s+5]);
      end;
    readln;
    end.

  14. #14
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut Ligue des champions [ poules]
    bonjour,
    nous sommes au stade des poules, mais nous avons un petit problème.

    alors nous avons nos 32 équipes (16 issues du 3ème tour et 16 arrivant que maintenant).
    nous les avons classées aléatoirement mais comment les classer dans des poules (8 poules de 4 équipes).

    si vous pouvez nous aider ce serai sympa.

    merci.

  15. #15
    Rédacteur/Modérateur
    Avatar de M.Dlb
    Inscrit en
    Avril 2002
    Messages
    2 464
    Détails du profil
    Informations personnelles :
    Âge : 39

    Informations forums :
    Inscription : Avril 2002
    Messages : 2 464
    Points : 4 311
    Points
    4 311
    Par défaut
    Classés comment ? Si c'est dans un tableau, ne suffit-il pas de couper le tableau en 4 ?
    M.Dlb - Modérateur z/OS - Rédacteur et Modérateur Pascal

  16. #16
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    174
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 174
    Points : 53
    Points
    53
    Par défaut
    alors voici les codes de la procedure pour les poules.
    nous avons reussit à les classé en 8 poules de 4 équipes mais maintenant le problème est que certaine équipes aparaissent plusieurs fois dans la meme poule.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    {---------------------------------poules ---------------------------------}
    procedure poules;
     
      const c=33;
     
      var tabi,tabf:array[1..c] of string;
      var i,j,k,l,n,p,q,s,t,u,v:integer;
     
    begin
    clrscr;
     
     
     randomize;
       for v:=1 to 16 do tabi[v]:=qualif3[v];
     
    tabi[17]:='  ESP  FC Barcelona ';
    tabi[18]:='  ESP  Real Madrid FC';
    tabi[19]:='  ENG  Chelsea FC';
    tabi[20]:='  ENG  Manchester United FC';
    tabi[21]:='  ITA  FC Internazionale';
    tabi[22]:='  ITA  AS Roma';
    tabi[23]:='  FRA  Olympique Lyonnais';
    tabi[24]:='  FRA  FC Girondins de Bordeaux';
    tabi[25]:='  GER  FC Bayern Munchen';
    tabi[26]:='  GER  Werder Bremen';
    tabi[27]:='  POR  FC Porto';
    tabi[28]:='  POR  Sporting Clube de Portugal';
    tabi[29]:='  NED  PSV Eindhoven';
    tabi[30]:='  GRE  Olympiacos CFP ';
    tabi[31]:='  BEL  RSC Anderlecht ';
    tabi[32]:='  SCO  Celtic FC';
     
     
    for j:=1 to c do
      begin
      n:=random(c+1-j)+1;
      tabf[c-j+1]:=tabi[n];
      for k:=n to c-j do tabf[k]:=tabi[k+1];
      for p:=1 to n-1 do tabf[p]:=tabi[p];
      for q:=1 to c   do tabf[q]:=tabf[q];
      end;
     
    for q:=1 to 4 do
      begin
      gotoXY(1,1+q);
      writeln(tabf[q]);
      end;
    for q:=5 to 8 do
      begin
      gotoXY(1,5+q);
      writeln(tabf[q]);
      end;
    for q:=9 to 12 do
      begin
      gotoXY(1,10+q);
      writeln(tabf[q]);
      end;
    for q:=13 to 16 do
      begin
      gotoXY(1,15+q);
      writeln(tabf[q]);
      end;
    for q:=17 to 20 do
      begin
      gotoXY(45,q-15);
      writeln(tabf[q]);
      end;
    for q:=21 to 24 do
      begin
      gotoXY(45,q-14);
      writeln(tabf[q]);
      end;
    for q:=25 to 28 do
      begin
      gotoXY(45,q-13);
      writeln(tabf[q]);
      end;
    for q:=29 to 32 do
      begin
      gotoXY(45,q-12);
      writeln(tabf[q]);
      end;
     
     
    end;

Discussions similaires

  1. Programme : Table des symboles
    Par Premium dans le forum C
    Réponses: 13
    Dernier message: 02/11/2017, 19h15
  2. [Modèle Relationnel] Ligue des champions
    Par gibsonSG_76 dans le forum Schéma
    Réponses: 7
    Dernier message: 05/11/2012, 22h03
  3. Lancer un programme avec des arguments via IE...
    Par petozak dans le forum Général Conception Web
    Réponses: 6
    Dernier message: 24/03/2006, 11h51
  4. [Classpath][execution] executer un programme avec des jar.
    Par LoLoSS dans le forum Général Java
    Réponses: 11
    Dernier message: 26/08/2004, 11h45
  5. Methode de programmation sur des gros projets
    Par dynobremo dans le forum EDI
    Réponses: 10
    Dernier message: 08/06/2004, 02h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo