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

不是说算法一样程序就一样,那么说,只要知道算法,就不用写程序了,仔细检查你的程序吧

Posted by hawk at 2005-04-25 22:33:48 on Problem 2386
In Reply To:完全一样的算法,我的怎么是wa? Posted by:tide713 at 2005-04-22 22:23:46
> 下面是我的程序,过不了,不知道为什么。
> #include<stdio.h>
> #include<stdlib.h>
> #include<iostream.h>
> char aaa[102][102];
> int n1,m1;//要输入的变量,表示行和列
> int b[8][2]={{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,-1},{1,-1},{-1,1}};//在递归的时候向八个方向扫描时用
> int xunhuan(int i,int j)
> {   int k;
>     
> 		  aaa[i][j]='.';
>                    
> 				  //if(a////////////////////////////////////////////
> 			      for( k=0;k<8;k++)
> 				  {    int b1=b[k][0];
> 				       int b2=b[k][1];
> 					   i=i+b1;
> 					   j=j+b2;
>                         
> 					    if(i>=0&&i<n1&&j>=0&&j<m1&&aaa[i][j]=='W')
> 						  xunhuan(i,j);
> 						else
> 						{i=i-b1;j=j-b2;}
> 				
> 
> 				  }
> 
> 	return 1;
> }
> void main()
> {    int i,j;
>      
>      //int n,m;
> 	 cin>>n1>>m1;
> 	 for(i=0;i<n1;i++)
> 	 cin>>aaa[i];     //输入数组
> 	 int bbb=0;
> 	 for(i=0;i<n1;i++)
> 		 for(j=0;j<m1;j++)
> 		 {   
> 			 if(aaa[i][j]=='W')
> 			 {   bbb++;
> 				 xunhuan(i,j);      //调用函数扫描
> 			 }
> 		 }
> 		 cout<<bbb<<endl;
> 
> }

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