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 646462970 at 2010-06-16 18:26:42 on Problem 2612
#include<iostream>
using namespace std;
int main()
{
	char map[20][20],out[20][20];
	memset(map,'.',sizeof(map));
	memset(out,'.',sizeof(out));
	int i,j,n,lei;
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			cin>>map[i][j]; 
    char op[20][20];
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			cin>>op[i][j];
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				lei=0;
				if(op[i][j]=='x')
				{
					if(map[i][j]=='*')
					{
						for(i=1;i<=n;i++)
							for(j=1;j<=n;j++)
								if(map[i][j]=='*')
									out[i][j]='*';
								goto out;
					}
					for(int k=i-1;k<i+2;k++)
						for(int s=j-1;s<j+2;s++)
							if(!(s==j && k==i))
								if(map[k][s]=='*')
									lei++;	
								out[i][j]=lei+48;
				}
			}
out:	for(i=1;i<=n;i++,cout<<endl)
			for(j=1;j<=n;j++)
				cout<<out[i][j];
	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