求各门各派的c++大神犇告诉我哪里错了

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
int cell[1010][1010],vis[1010][1010],m,n,t;
char x;
int main(){
scanf("%d%d%d",&m,&n,&t);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>x;
if(x=='1'){
vis[i][j]=1;
cell[i][j]=1;
}
else{
vis[i][j]=0;
cell[i][j]=0;
}
}
}
t--;
while(t){
t--;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
int sum=vis[i+1][j]+vis[i-1][j]+vis[i][j+1]+vis[i][j-1]+vis[i+1][j+1]+vis[i+1][j-1]+vis[i-1][j+1]+vis[i-1][j-1];
if(vis[i][j]==1){
if(sum<2){
cell[i][j]=0;
}
if(sum==3&&sum==2){
cell[i][j]=1;
}
if(sum>3){
cell[i][j]=0;
}
}
else{
if(sum==3){
cell[i][j]=1;
}
else{
cell[i][j]=0;
}
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
vis[i][j]=cell[i][j];
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
printf("%d ",cell[i][j]);
}
printf("\n");
}
return 0;
}

4 条评论

• @ 2018-03-07 20:22:32

在线等

• @ 2018-03-07 20:21:53

??

• @ 2018-03-07 20:20:01

233

• @ 2018-03-07 20:19:29

...

• 1

ID
1415

6

(无)

1864

514

28%