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

求教啊~~怎么试怎么对啊到底哪错了呢,请高手指点一二!!!(C程序,方法有点笨!)

Posted by fcl91244 at 2005-05-15 16:10:49 on Problem 1562
#include<stdio.h>
#include<string.h>
void main()
{char s[101][101];
 int l,m,n,i,j,count,end[101],k=0;

 for(l=0;;l++)
 {scanf("%d %d",&m,&n);
  if(m==0) break;

   for(i=0;i<m;i++)
	   scanf("%s",&s[i]);

   for(i=0,count=0;i<m;i++)
	   for(j=0;j<n;j++)
	   {if(s[i][j]=='*'&&s[i-1][j-1]=='0')
	        if(s[i-1][j]=='@') s[i-1][j]='0';
		if(s[i][j]=='*'&&s[i-1][j-1]=='0')
			if(s[i][j-1]=='@') s[i][j-1]='0';
		if(s[i][j]=='*'&&s[i-1][j]=='0')
			if(s[i-1][j-1]=='@') s[i-1][j-1]='0';
		if(s[i][j]=='*'&&s[i-1][j]=='0')
			if(s[i][j-1]=='@') s[i][j-1]='0';
		if(s[i][j]=='*'&&s[i-1][j]=='0')
			if(s[i-1][j+1]=='@') s[i-1][j+1]='0';
		if(s[i][j]=='*'&&s[i-1][j]=='0')
			if(s[i][j+1]=='@') s[i][j+1]='0';
		if(s[i][j]=='*'&&s[i-1][j+1]=='0')
            if(s[i-1][j]=='@') s[i-1][j]='0';
		if(s[i][j]=='*'&&s[i-1][j+1]=='0')
			if(s[i][j+1]=='@') s[i][j+1]='0';
		if(s[i][j]=='*'&&s[i][j-1]=='0')
			if(s[i-1][j-1]=='@') s[i-1][j-1]='0';
		if(s[i][j]=='*'&&s[i][j-1]=='0')
			if(s[i-1][j]=='@') s[i-1][j]='0';
		if(s[i][j]=='*'&&s[i][j-1]=='0')
			if(s[i+1][j-1]=='@') s[i+1][j-1]='0';
		if(s[i][j]=='*'&&s[i][j-1]=='0')
			if(s[i+1][j]=='@') s[i+1][j]='0';
        if(s[i][j]=='*'&&s[i][j+1]=='0')
			if(s[i-1][j]=='@') s[i-1][j]='0';
		if(s[i][j]=='*'&&s[i][j+1]=='0')
			if(s[i-1][j+1]=='@') s[i-1][j+1]='0';
		if(s[i][j]=='*'&&s[i][j+1]=='0')
			if(s[i+1][j]=='@') s[i+1][j]='0';
		if(s[i][j]=='*'&&s[i][j+1]=='0')
			if(s[i+1][j+1]=='@') s[i+1][j+1]='0';
		if(s[i][j]=='*'&&s[i+1][j-1]=='0')
			if(s[i][j-1]=='@') s[i][j-1]='0';
		if(s[i][j]=='*'&&s[i+1][j-1]=='0')
			if(s[i+1][j]=='@') s[i+1][j]='0';
		if(s[i][j]=='*'&&s[i+1][j]=='0')
			if(s[i][j-1]=='@') s[i][j-1]='0';
		if(s[i][j]=='*'&&s[i+1][j]=='0')
			if(s[i+1][j-1]=='@') s[i+1][j-1]='0';
		if(s[i][j]=='*'&&s[i+1][j]=='0')
			if(s[i+1][j+1]=='@') s[i+1][j+1]='0';
		if(s[i][j]=='*'&&s[i+1][j]=='0')
			if(s[i][j+1]=='@') s[i][j+1]='0';
		if(s[i][j]=='*'&&s[i+1][j+1]=='0')
			if(s[i][j+1]=='@') s[i][j+1]='0';
		if(s[i][j]=='*'&&s[i+1][j+1]=='0')
			if(s[i+1][j]=='@') s[i+1][j]='0';
		if(s[i][j]=='@')
			if(s[i-1][j-1]=='0'||s[i-1][j]=='0'||s[i-1][j+1]=='0'||s[i][j-1]=='0'||s[i][j+1]=='0'||s[i+1][j-1]=='0'||s[i+1][j]=='0'||s[i+1][j+1]=='0')
				s[i][j]='0';
		if(s[i][j]=='@'&&s[i-1][j-1]!='0'&&s[i-1][j]!='0'&&s[i-1][j+1]!='0'&&s[i][j-1]!='0'&&s[i][j+1]!='0'&&s[i+1][j-1]!='0'&&s[i+1][j]!='0'&&s[i+1][j+1]!='0')
		{count++;s[i][j]='0';}
	   }
	  end[k++]=count;
 }
 for(i=0;i<k;i++)
	 printf("%d\n",end[i]);
}















	          
	       


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