#include <iostream> using namespace std; void find(char s[130][130],int m,int n){ s[m][n] = '0'; int i,j; for(i=m-1;i<=m+1;i++){ for(j=n-1;j<=n+1;j++){ if(s[i][j]=='1') find(s,i,j); } } } int main(){ int m,n,k; char[130][130]; while(scanf("%d%d",&m,&n)!=EOF&&m!=0&&n!=0){ for(int j=0;j<m;j++){ scanf("%s",&s[j]); } k=0; for(int i=0;i<m;i++){ for(int j=0;j<n;i++){ if(s[i][j]=='1'){ find(s,i,j); k++; } } } printf("%d\n",k); } return 0; } /* Main.cc: In function 'int main()': Main.cc:17:7: error: expected unqualified-id before '[' token char[130][130]; ^ Main.cc:20:19: error: 's' was not declared in this scope scanf("%s",&s[j]); ^ Main.cc:26:12: error: 's' was not declared in this scope if(s[i][j]=='1'){ ^ */ |
Double click to view unformatted code.