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

纯模拟 140K 0MS

Posted by 1458254357 at 2015-07-06 20:40:21 on Problem 3752
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;

const char a[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	char s[100][100],d='E';
	int o=-1,x=1,y=0,f=0;
	memset(s,' ',sizeof(s));
	for (int i=1;i<=n*m;i++)
	{
		switch (d)
		{
			case 'W':s[x][--y]=a[(++o)%26]; break;
			case 'S':s[++x][y]=a[(++o)%26]; break;
			case 'E':s[x][++y]=a[(++o)%26]; break;
			case 'N':s[--x][y]=a[(++o)%26]; break;
		}
		if (x==f+1&&y==1+f) f++;
		if (d=='S'&&(isupper(s[x+1][y])||x==n)) d='W';
		if (d=='E'&&(isupper(s[x][y+1])||y==m)) d='S';
		if (d=='N'&&(isupper(s[x-1][y])||x==1)) d='E';
		if (d=='W'&&(isupper(s[x][y-1])||y==1)) d='N';
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
			printf("   %c",s[i][j]);
		printf("\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