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

50题留名 从08年12月开始做的哦 加油!(附代码)

Posted by john081201 at 2009-01-01 15:13:21 on Problem 1656
//由于比较菜 这题才会用字符串比较函数strcmp 要多看书多学习呀!
#include<stdio.h>
#include<string.h>
int main()
{
	int a[101][101]={0};
	int t,i,j,x,y,l,count;
	char str[10];
	scanf("%d",&t);
	while(t--)
	{
		memset(str,0,sizeof(str));
		scanf("%s %d %d %d",&str,&x,&y,&l);
		count=0;
		if(strcmp(str,"BLACK")==0)
			for(i=x;i<=x+l-1;i++)
				for(j=y;j<=y+l-1;j++)
					a[i][j]=1;
		if(strcmp(str,"WHITE")==0)
             for(i=x;i<=x+l-1;i++)
				for(j=y;j<=y+l-1;j++)
					a[i][j]=0;
		if(strcmp(str,"TEST")==0)
		{  
			for(i=x;i<=x+l-1;i++)
				for(j=y;j<=y+l-1;j++)
					 if(a[i][j]==1)
						 count++;
			printf("%d\n",count);
		}
	}
	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