Comment detail
ライフゲーム (Nested Flatten)題意を間違えたみたいなんで追加修正
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 | void init_life(int a[HEIGHT][WIDTH]){
int x,y;
int count=0;
for(y=0;y<HEIGHT;y++){
for(x=0;x<WIDTH;x++){
a[y][x]=0;
}
}
srand(time(NULL));
do{
x=rand()/(RAND_MAX/WIDTH);
y=rand()/(RAND_MAX/HEIGHT);
if(calc_life(a,x,y)<=(2+(rand()/(RAND_MAX/2)))){
a[y][x]=1;
count++;
}
}while(count<((HEIGHT*WIDTH)*(2+(rand()/(RAND_MAX/2)))/10));
}
int main(){
int a[HEIGHT][WIDTH];
init_life(a);
lifegame(a);
return 0;
}
|



こう。 #5380() [ C ] Rating0/0=0.00
Rating0/0=0.00-0+
1 reply [ reply ]