所以我在 Linux 上使用 C 为生命游戏编写这段代码,但我收到了这个警告! 此警告是什么意思,我该如何解决?我写的代码是:
#include <stdio.h>
#include <string.h>
#include <omp.h>
#include <stdlib.h>
#include <assert.h>
#define MAX_N 2000
int plate[2][(MAX_N + 2) * (MAX_N + 2)];
int which = 0;
int n;
int live(int index){
return (plate[which][index - n - 3]
+ plate[which][index - n - 2]
+ plate[which][index - n - 1]
+ plate[which][index - 1]
+ plate[which][index + 1]
+ plate[which][index + n + 1]
+ plate[which][index + n + 2]
+ plate[which][index + n + 3]);
}
void iteration(){
#pragma omp parallel for schedule(static)
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
int index = i * (n + 2) + j;
int num = live(index);
if(plate[which][index]){
plate[!which][index] = (num == 2 || num == 3) ?
1 : 0;
}else{
plate[!which][index] = (num == 3);
}
}
}
which = !which;
}
void print_plate(){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
printf("%d", plate[which][i * (n + 2) + j]);
}
printf("n");
}
printf("