POJ 1656 Counting Black G++

#include <iostream>
using namespace std;
//抄博友程序 
int da[104][104];//white
int main()
{
	int n;
	cin>>n;
	for(int o=0;o<n;o++)
	{
		string com;
		int x,y,l;
		cin>>com>>x>>y>>l;
		int js=0;
		for(int i=x;i<x+l;i++)
		{
			for(int j=y;j<y+l;j++)
			{
				if(com=="BLACK")
				{
					da[i][j]=1;
				}else if(com=="WHITE")
				{
					da[i][j]=0;
				}else if(com=="TEST")
				{
					if(da[i][j]==1)
					{
						js++;
					}
				}
			}
		}
		if(com=="TEST")
		{
			cout<<js<<endl;
		}
	}
	return 0;
}
发布了1118 篇原创文章 · 获赞 9 · 访问量 33万+

猜你喜欢

转载自blog.csdn.net/woniupengpeng/article/details/104481765