Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

给个AC的程序

Posted by 40962501 at 2017-04-22 22:47:02 on Problem 2386
/*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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator