int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int Record[200][200];
void dfs(int** isConnected,int x,int y,int isConnectedSize,int isConnectedColSize){
Record[x][y]=1;
for(int a=0;a<isConnectedColSize;a++){
if(Record[x][a]==0&&isConnected[x][a]==1){
Record[a][a]=1;
Record[x][a]=1;
dfs(isConnected,a,x,isConnectedSize,isConnectedColSize);
}
}
}
int findCircleNum(int** isConnected, int isConnectedSize, int* isConnectedColSize){
int count=0;
for(int a=0;a<200;a++){
for(int b=0;b<200;b++){
Record[a][b]=0;
}
}
for(int a=0;a<isConnectedSize;a++){
for(int b=0;b<isConnectedColSize[a];b++){
if(isConnected[a][b]==1&&Record[a][b]==0){
dfs(isConnected,a,b,isConnectedSize,isConnectedColSize[a]);
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
printf("%d ",Record[i][j]);
}
}
count++;
}
}
}
return count;
}
|