Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
给个AC的程序/*ID:40962501 NAME:2386.CPP */ #include<iostream> #include<stdio.h> #define MAX 101 int c[MAX][MAX]; //用来放置相应的数据 using namespace std; int i,j,count=0; void search(int x,int y,int isfirst){ if(c[x][y]==0) return; if(isfirst) count++; c[x][y]=0; for(int l=0;l<3;l++) for(int m=0;m<3;m++){ if(x-l+1>=0&&x-l+1<=i&&y-m+1>=0&&y-m+1<=j) search(x-l+1,y-m+1,0); } } int main(){ int n; //cin>>n; //while (n--){ cin>>i>>j; char c1; for(int m=0;m<i;m++) for(int n=0;n<j;n++){ cin>>c1; if(c1=='.') c[m][n]=0; else c[m][n]=1; } for(int m=0;m<i;m++) for(int n=0;n<j;n++){ search(m,n,1); } cout<<count<<endl; count=0; // } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator