摘要:貌似水题越来越少了,好不容易才找到一题。。。
#include <iostream>
using namespace std;
const int size = 100;
int array[size+1][size+1] = { 0 };
void operation(string command, int x1, int y1, int x2, int y2)
{
if( command == "BLACK" ){
for(int i=x1; i<=x2; i++){
for(int j=y1; j<=y2; j++){
array[i][j] = 1;
}
}
}
if( command == "WHITE" ){
for(int i=x1; i<=x2; i++){
for(int j=y1; j<=y2; j++){
array[i][j] = 0;
}
}
}
int black = 0;
if( command == "TEST" ){
for(int i=x1; i<=x2; i++){
for(int j=y1; j<=y2; j++){
black += array[i][j];
}
}
cout << black << endl;
}
}
int main()
{
int n;
cin >> n;
while( n > 0 ){
string command;
int x1, y1, l;
cin >> command;
cin >> x1 >> y1 >> l;
int x2 = x1+l-1;
int y2 = y1+l-1;
operation(command, x1, y1, x2, y2);
n--;
}
return 0;
}