I'm writing a simulation in population genetics and am having a problem setting up the initial population. The problem boils down to this...
int test[1][1][1];
test[0][0][1]=1;
test[1][0][0]=2;
printf("test: %d\n",test[0][0][1]);
Why does this print 2? I feel like it should print 1. I've searched forums for an answer, but haven't been able to find one. If there's one out there, please point me to it. Thank you.
If you're interested in the background, I'm setting up a 3D array to represent a population. The first index contains the number of the individual, the second index contains the loci, and the third index contains the allele (only 2, since these are diploid organisms). All the individuals should initially have one of each allele, so I run
//Set up initial population
for (i=0;i<N;i++){
for (j=0;j<loci;j++){
population[i][j][0]=-1;
population[i][j][1]=1;
}
}
(loci is set to 1 for testing purposes) but only the last individual has both -1 and 1. Individuals 0 to N-2 have -1 and -1, and this is a problem.