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
| struct DNA{
int globalValue;
int globalWeight;
int dna[];
};
void display(int nbrObjet, int people, struct DNA* population)
{
int i,j;
for(i=0;i<people;i++)
{
for(j=0;j<nbrObjet;j++)
{
printf("%d", population[i].dna[j]);
}
printf("\n");
}
}
struct DNA population[people];
for(i=0;i<people;i++)
{
for(j=0;j<nbrObjet;j++)
{
population[i].dna[j] = rand()%2;
printf("%d", population[i].dna[j]);
}
printf("\n");
}
printf("\n");
display(nbrObjet, people,population);
printf("\n");
for(i=0;i<people;i++)
{
for(j=0;j<nbrObjet;j++)
{
printf("%d", population[i].dna[j]);
}
printf("\n");
} |
Partager