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

Could anyone give me some special datas? Here is my code! Headache!!!

Posted by 444444 at 2006-11-19 22:12:44 on Problem 1495
#include <cstdio>

char map[10][8];

void init()
{
	int i,j;
	char a='N';
	for(i=0;i<=9;i++)
		for(j=1;j<=7;j++)
			map[i][j]='Y';
	map[0][7]=a;
	map[9][5]=a;
	for(i=4;i<=7;i++)
		map[7][i]=a;
	map[6][2]=a;
	map[5][2]=map[5][5]=a;
	map[4][1]=map[4][4]=map[4][5]=a;
	map[3][5]=map[3][6]=a;
	map[2][3]=map[2][6]=a;
	map[1][1]=a;
	for(i=4;i<=7;i++)
		map[1][i]=a;
}

int main()
{
	init();
	int n,i,j,k;
	char a[12][8];
	while(scanf("%d",&n) && n)
	{
		for(i=1;i<=n;i++)
		{
			getchar();
			for(j=1;j<=7;j++)
				scanf("%c",&a[i][j]);
		}
		int flag=9;
		bool ans=0;
		while(flag>=0 && flag-n+1>=0)
		{
			for(i=1,j=flag;i<=n;i++,j--)
			{
				for(k=1;k<=7;k++)
				{
					if(map[j][k]=='N' && a[i][k]=='Y')
						break;
				}
				if(k<=7)
					break;
			}
			if(i>n)
			{
				ans=1;
				break;
			}
			flag--;
		}
		if(ans==1)
			printf("MATCH\n");
		else
			printf("MISMATCH\n");
	}
	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