| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
50题留名 从08年12月开始做的哦 加油!(附代码)//由于比较菜 这题才会用字符串比较函数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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator