BruNews
Messages postés21040Date d'inscriptionjeudi 23 janvier 2003StatutModérateurDernière intervention21 août 2019
-
19 mai 2004 à 20:46
der_kaiser
Messages postés2Date d'inscriptionmercredi 14 avril 2004StatutMembreDernière intervention17 août 2004
-
17 août 2004 à 11:36
14 Ko de download pour tester et me dire si resultats coherents.
C'est un truc qu'on m'avait demande et que j'avais deja poste en source.
Le prob, je n'avais pas assez teste et comme je suis trop bon en sport...
Quand sera tout bon je remettrai.
DeAtHCrAsH
Messages postés2670Date d'inscriptionvendredi 25 janvier 2002StatutMembreDernière intervention 6 février 2013 19 mai 2004 à 21:09
J'ai fait une dizaine de jeu d'essai aléatoire et je n'ai trouvé aucune erreur dans les résultat ....
Faut du temps pour tous tester.... vraiment beaucoup de temps!!
vecchio56
Messages postés6535Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention22 août 201014 20 mai 2004 à 00:55
Résultats non cohérents puisque 42 journées pour 20 équipes, dont la 42ème qui ne contient qu'un match
On voudrait plutut 38 journée de 10 matches
En fait de problème de sport, c'est plutot un problème de math...
Profitons de ce sujet pour saluer la magnifique défaite des Marseillais en finale de l'UEFA avec un Barthez héroïque
Vous n’avez pas trouvé la réponse que vous recherchez ?
vecchio56
Messages postés6535Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention22 août 201014 20 mai 2004 à 12:39
j'ai essayé, et j'obtiens des résultats comparables aux tiens, mais j'ai peut-être une piste:
On veut organiser un championnat entre n équipes, en un nombre minimal de journées. Chaque journée, chaque équipe rencontre au plus une équipe, le championnat est terminé lorsque toutes les équipes se sont rencontrées une fois.
Combien de journées au moins sont nécessaires pour un championnat entre n équipes.
On suppose que n est une puissance de 2. n = 2k et on suppose que les équipes sont numérotées de 1 à n. Ecrire en pseudo-langage de programmation un algorithme qui donne la liste des rencontres pour chaque journée en utilisant le principe suivant :
On répartit les équipes en deux groupes de même taille ; les équipes de chaque groupe s'affrontent dans un championnat complet de n/2 équipes ; ces deux championnats étant organisés en parallèle. Puis on organise les rencontres entre les deux groupes en divisant chaque groupe en deux.
Evaluer le nombre d'opérations effectuées par le programme de la question précédente. Peut-on faire mieux ?
Donner un algorithme d'organisation de tournoi basé sur un principe complètement différent. Indication : on pensera à faire " tourner " des équipes suivant une permutation circulaire bien choisie.
Peut-on généraliser la méthode de la question 2 et celle de la question 4 à un nombre quelconque d'équipes, tout en gardant un principe similaire.
Hylvenir
Messages postés364Date d'inscriptionmercredi 11 février 2004StatutMembreDernière intervention 5 octobre 20062 20 mai 2004 à 20:48
Pour ma culture perso, si tu as mieux je suis preneur.
for( int li = 0; li < NB-1; ++li )
{
for( int co = 0; co < NB-1; ++co )
{
int val = (NB-co-li-1)%(NB-1)+1;
if ( val <= 0 ) val += NB-1;
if ( val==li+1 ){
val = 14;
tab[co][NB-1] = li+1;
}
tab[co][li] = val;
}
}
int main (void)
{
typedef struct ustat // Structure contenant les statistiques des participants
{
char* Nom;
int vict,nul,def,pour,contre;
} stats;
int score1,score2; // Variables pour les scores des matches
int hg,wh; // Contenant la hauteur et la largeur de l'‚cran
const int nb_max=20;
const int nb_min=4;
int i,j,m,l; // Compteurs
int Nombre; // Nombre des participants
char participants[nb_max][16]; // Tableau comprenant les noms
char ordre[nb_max][16];
int passage[nb_max];
int a,pts1,pts2; // Variables interm‚diaires
char* calendrier [nb_max][nb_max]; // Contenant les matches
int scores[nb_max][nb_max];
char* inter;
int aa,bb;
stats struc1,struc2;
// Tableau contenant les classements
stats standings[nb_max];
hg=ti.screenheight;
wh=ti.screenwidth;
/*
*/
//////////////////// SAISIE DES PARTICIPANTS /////////////////////////////
clrscr();
printf("Vous allez maintenant donner le nombre de participants (par la suite les noms) \n");
printf("qui doit ˆtre un nombre pair sup‚rieur ou ‚gal … %d et inf‚rieur \n",nb_min);
printf("ou ‚gal … %d \n",nb_max);
printf("********************************************************* \n");
printf("Remarques : \n");
printf("1/ Lorsque vous saisissez les noms des participants n'utilisez pas \n");
printf("l'espace ou alors si vous pr‚f‚rez, utilisez le blanc soulign‚ "_" \n");
printf("2/ Les noms ne doivent pas d‚passer 15 caractŠres, sinon problŠmes \n");
printf("*********************************************************\n");
printf("Nombre = ");
do
{
gotoxy(10,10);
clreol();
scanf("%d",&Nombre);
}
while (Nombre<nb_min || Nombre>nb_max || Nombre % 2 != 0);
clrscr();
for (i=0;i<Nombre;i++)
{
printf("Donner le nom du participant Nø %2d : ",i+1);
scanf("%s",participants[i]);
standings[i].Nom=participants[i];
}
for (i=0;i<Nombre;i++)
{
printf("Nom du participant Nø %d : %10s \n",i+1,participants[i]);
}
printf("\n \n Appuyez sur une touche pour continuer : ");
getch();
//////////////// PREPARATION AU TIRAGE AU SORT ALEATOIRE ////////////////////
clrscr();
for (i=0;i<Nombre;i++)
{
passage[i]=0;
/* printf("%d ",passage[i]); */
}
printf("\n");
randomize();
for (i=0;i<Nombre;i++)
{
do
{
a=random(Nombre+1);
/* printf("%d \n",a); */
}
while (passage[a-1]==1 || a==0);
passage[a-1]=1;
for (j=0;j<8;j++)
{
ordre[i][j]=participants[a-1][j];
}
}
/*
for (i=0;i<Nombre;i++)
{
printf("Ordre %i : %-10s \n",i+1,ordre[i]);
}
*/
getch();
////////////////////////// REPLISSAGE DU CALENDRIER //////////////////
clrscr();
printf("Temps de chargement, patientez s'il vous plaŒt ... \n");
delay (4000);
clrscr();
//////////////////// 1ERE JOURNEE /////////////////////////////////////
for (i=0;i<Nombre;i++)
{
calendrier[0][i] = ordre [i];
}
/*
printf(" ********** 1Šre journ‚e *********** \n");
for (i=0;i<Nombre;i=i+2)
{
printf("%s - %s \n",calendrier[0][i],calendrier[0][i+1]);
}
*/
getch();
/////////////// LA SUITE DE LA COMPRETITION ////////////////////////
a=4;
i=0;
for (a=4,i=0;i<Nombre-4;i=i+2,a=a+2)
{
passage[i]=Nombre-a;
passage[i+1]=Nombre-(a-1);
}
/*
for (i=0;i<Nombre-4;i++)
{
printf("%u \n",passage[i]);
}
*/
printf("Appuyez sur une touche pour voir les matches ... \n");
getch();
for (j=1;j<Nombre-1;j++)
{
for (i=0;i<Nombre-4;i++)
{
calendrier[j][i]=calendrier[j-1][passage[i]-1];
}
calendrier[j][i]=calendrier[j-1][Nombre-2];
calendrier[j][i+1]=calendrier[j-1][0];
calendrier[j][i+2]=calendrier[j-1][Nombre-3];
calendrier[j][i+3]=calendrier[j-1][Nombre-1];
}
for (j=0;j<Nombre-1;j=j+2)
{
inter=calendrier[j][Nombre-1];
calendrier[j][Nombre-1]=calendrier[j][Nombre-2];
calendrier[j][Nombre-2]=inter;
}
for (j=0;j<Nombre-1;j++)
{
printf("%2i³",j+1);
for (i=0;i<Nombre;i=i+2)
{
printf("%5.5s-%-5.5s³",calendrier[j][i],calendrier[j][i+1]);
}
printf("\n");
getch();
getch();
}
/////////////////// ENREGISTREMENT DES RESULTATS ///////////////////////////
////////////////// INITIALISATION DES CLASSEMENTS A ZERO //////////////////
clrscr();
for (i=0;i<Nombre;i++)
{
standings[i].vict=0;
standings[i].nul=0;
standings[i].def=0;
standings[i].pour=0;
standings[i].contre=0;
}
getch();
clrscr();
gotoxy((3*wh)/8,hg/2);
printf("SAISIE DES RESULTATS ");
delay (2000);
clrscr();
gotoxy((3*wh)/8,hg/2);
printf("P H A S E A L L E R");
delay(2000);
for (i=0;i<Nombre-1;i++)
{
clrscr();
gotoxy((3*wh)/8,hg/2);
printf(" %d%s Journ‚e \n",i+1,i<1?"Šre":"Šme");
delay(2000);
for (j=0;j<Nombre;j=j+2)
{
clrscr();
printf("%-13s : \n",calendrier[i][j]);
printf("%-13s : \n",calendrier[i][j+1]);
printf("\n");
gotoxy(16,1); scanf("%i",&score1);
gotoxy(16,2); scanf("%i",&score2);
aa=-1;
bb=-1;
do {aa++;} while (strcmp(standings[aa].Nom,calendrier[i][j]) != 0);
struc1 = standings[aa];
do {bb++;} while (strcmp(standings[bb].Nom,calendrier[i][j+1]) != 0);
struc2 = standings[bb];
{
standings[aa].pour=standings[aa].pour+score1;
standings[bb].pour=standings[bb].pour+score2;
standings[aa].contre=standings[aa].contre+score2;
standings[bb].contre=standings[bb].contre+score1;
if (score1>score2)
{
standings[aa].vict++;
standings[bb].def++;
}
else
if (score1 == score2)
{
standings[aa].nul++;
standings[bb].nul++;
}
else
if (score1<score2)
{
standings[aa].def++;
standings[bb].vict++;
}
}
}
///////////////////// TRI DU CLASSEMENT /////////////////////////
for (l=0;l<Nombre*5;l++)
for (m=0;m<Nombre-1;m++)
{
pts1=standings[m].vict*3+standings[m].nul;
pts2=standings[m+1].vict*3+standings[m+1].nul;
if (pts2>pts1)
{
struc1=standings[m];
standings[m]=standings[m+1];
standings[m+1]=struc1;
}
}
//////////////////////CLASSEMENT FINAL ///////////////////////
clrscr();
printf("******************** CLASSEMENT *************************\n");
printf(" J G N P p. c. +/- pts\n");
for (m=0;m<Nombre;m++)
{
printf("%-16s ",standings[m].Nom);
printf("%3i ",standings[m].vict+standings[m].nul+standings[m].def);
printf("%3i ",standings[m].vict);
printf("%3i ",standings[m].nul);
printf("%3i ",standings[m].def);
printf("%4i ",standings[m].pour);
printf("%4i ",standings[m].contre);
printf("%4d ",standings[m].pour - standings[m].contre);
printf("%4i ",standings[m].vict*3+standings[m].nul);
printf("\n");
}
printf("**********************************************************");
getch();
getch();
}
clrscr();
gotoxy((3*wh)/8,hg/2);
printf("P H A S E R E T O U R");
delay(2000);
for (i=0;i<Nombre-1;i++)
{
clrscr();
gotoxy((3*wh)/8,hg/2);
printf(" %d%s Journ‚e \n",i+1,i<1?"Šre":"Šme");
delay(2000);
for (j=0;j<Nombre;j=j+2)
{
clrscr();
printf("%-13s : \n",calendrier[i][j+1]);
printf("%-13s : \n",calendrier[i][j]);
printf("\n");
gotoxy(16,1); scanf("%i",&score1);
gotoxy(16,2); scanf("%i",&score2);
aa=-1;
bb=-1;
do {aa++;} while (strcmp(standings[aa].Nom,calendrier[i][j+1]) != 0);
struc1 = standings[aa];
do {bb++;} while (strcmp(standings[bb].Nom,calendrier[i][j]) != 0);
struc2 = standings[bb];
{
standings[aa].pour=standings[aa].pour+score1;
standings[bb].pour=standings[bb].pour+score2;
standings[aa].contre=standings[aa].contre+score2;
standings[bb].contre=standings[bb].contre+score1;
if (score1>score2)
{
standings[aa].vict++;
standings[bb].def++;
}
else
if (score1 == score2)
{
standings[aa].nul++;
standings[bb].nul++;
}
else
if (score1<score2)
{
standings[aa].def++;
standings[bb].vict++;
}
}
}
///////////////////// TRI DU CLASSEMENT /////////////////////////
for (l=0;l<Nombre*5;l++)
for (m=0;m<Nombre-1;m++)
{
pts1=standings[m].vict*3+standings[m].nul;
pts2=standings[m+1].vict*3+standings[m+1].nul;
if (pts2>pts1)
{
struc1=standings[m];
standings[m]=standings[m+1];
standings[m+1]=struc1;
}
}
//////////////////////CLASSEMENT FINAL ///////////////////////
clrscr();
printf("******************** CLASSEMENT *************************\n");
printf(" J G N P p. c. +/- pts\n");
for (m=0;m<Nombre;m++)
{
printf("%-16s ",standings[m].Nom);
printf("%3i ",standings[m].vict+standings[m].nul+standings[m].def);
printf("%3i ",standings[m].vict);
printf("%3i ",standings[m].nul);
printf("%3i ",standings[m].def);
printf("%4i ",standings[m].pour);
printf("%4i ",standings[m].contre);
printf("%4d ",standings[m].pour - standings[m].contre);
printf("%4i ",standings[m].vict*3+standings[m].nul);
printf("\n");
}
printf("**********************************************************");
getch();
getch();
}
///////////////////// TRI DU CLASSEMENT /////////////////////////
for (j=0;j<Nombre*5;j++)
for (i=0;i<Nombre-1;i++)
{
pts1=standings[i].vict*3+standings[i].nul;
pts2=standings[i+1].vict*3+standings[i+1].nul;
l = standings[i].pour - standings[i].contre;
m = standings[i+1].pour - standings[i+1].contre;
if (pts2 == pts1 && m>l)
{
struc1=standings[i];
standings[i]=standings[i+1];
standings[i+1]=struc1;
}
}
//////////////////////CLASSEMENT FINAL ///////////////////////
clrscr();
printf("******************** CLASSEMENT *************************\n");
printf(" J G N P p. c. +/- pts\n");
for (i=0;i<Nombre;i++)
{
printf("%-16s ",standings[i].Nom);
printf("%3i ",standings[i].vict+standings[i].nul+standings[i].def);
printf("%3i ",standings[i].vict);
printf("%3i ",standings[i].nul);
printf("%3i ",standings[i].def);
printf("%4i ",standings[i].pour);
printf("%4i ",standings[i].contre);
printf("%4d ",standings[i].pour - standings[i].contre);
printf("%4i ",standings[i].vict*3+standings[i].nul);
printf("\n");
}
printf("**********************************************************");