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
| #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include "fnc.h"
#include <time.h>
void initTab(long resTab[15][15],long nbEquipes) // tout a 15 ou alors 0
{
long i = 0;
long j = 0;
for( i = 0 ; i < 15 ; i++)
{
for( j = 0 ; j < 15 ; j++)
{
if(i == j)
{
resTab[i][j] = 0;
}
else if (i >= j)
{
resTab[i][j] = 0;
}
else
{
resTab[i][j] = 1;
}//fin du else
}// fin du for(j
}//fin du for(1
}//fin de initTab
void aleatGen(long matchList[27][4][2], long resTab[15][15],long nbEquipes)
{
long i = 0;
long j = 0;
long k = 0;
long a = 0;
long b = 0;
long test1 = 0;
long test2 = 0;
long rempli = 0;
const int MAX = 14, MIN = 0;
for( rempli = 0; rempli < 105 ; rempli++)
{
while(condition(resTab, matchList, nbEquipes, test1, test2, i) != 1)
{
test1 = (rand() % (MAX - MIN + 1)) + MIN;
test2 = (rand() % (MAX - MIN + 1)) + MIN;
}//fin du while(condition)
resTab[test1][test2] = (resTab[test1][test2] + 1);
remplirMatchList(i, j, k, matchList, test1, test2);
j++;
if(j == 4)
{
j = 0;
i++;
}
}//fin du for(rempli)
i = 0;
j = 0;
k = 0;
for(i = 0; i < 27 ; i++)
{
printf("\n|\n");
for(j = 0; j < 4 ; j++)
{
for(k = 0; k < 2; k++)
{
printf("%ld", matchList[i][j][k]);
printf(" ");
}
printf(" --- ");
}
printf("\n|\n");
}
}//fin de la fonction
long condition(long resTab[15][15], long matchList[27][4][2], long nbEquipes, long test1, long test2, long i)
{
long a = 0;
long j = 0;
long k = 0;
if(resTab[test1][test2] = 0)
{
return 2;
}//fin du if(resTab
else
{
for(a = 0; a < nbEquipes ; a++)
{
for(j = 0; j < nbEquipes ; j++)
{
if(j > a)
{
if(resTab[test1][test2] > (resTab[a][j] + 1))
{
return 2;
}//fin if(restab
}//fin de if(j>
}//fin de for(j
}//fin de (fori
j = 0;
for(j = 0; j < 4 ; j++)
{
for(k = 0 ; k < 2 ; k++)
{
if(matchList[i][j][k] == test1 || matchList[i][j][k] == test2)
{
return 2;
}
}
}//fin for(j
if(test1 == test2)
{
return 2;
}
//QUAND JE RAJOUTE DE ICI
else if(i < 26)
{
for( i = 0; i < 26 ; i++)
{
for(j = 0; j < 4 ; j++)
{
k = 0;
if(matchList[i][j][k] == test1 && matchList[i][j][(k + 1)] == test2 && i != 27)
{
return 2;
}
else if(matchList[i][j][k] == test2 && matchList[i][j][(k +1)] == test1 && i != 27)
{
return 2;
}
}//for(j
}//for(i
}
// A ICI CA BUG!!!
return 1;
}//fin else
}//fin de condition
void remplirMatchList(long i,long j, long k,long matchList[27][4][2],long test1, long test2)
{
k = 0;
matchList[i][j][k] = test1;
k++;
matchList[i][j][k] = test2;
}//fin void remplir |
Partager