付之东流

程序是衣,算法为魂

原创 北大ACM第1656题 收藏

新一篇: 北大ACM第2418题  | 旧一篇: 北大ACM第1007题

北大ACM第1656题

#include <iostream>
using namespace std;

//   0   white
//   1   black

void Black( int a[][ 101 ], int x, int y, int len );
void White( int a[][ 101 ], int x, int y, int len );
void Test( int a[][ 101 ], int x, int y, int len );

int main()
{
    
int a[ 101 ][ 101 ] = 0 };
    
char s[ 6 ];
    
int n = 0, x = 0, y = 0, len = 0;
    cin 
>> n;
    
while( n > 0 )
    
{
        scanf(
"%s %d %d %d", s, &x, &y, &len );
        
if( strcmp( s, "BLACK" ) == 0 )
            Black( a, x, y, len );
        
else if( strcmp( s, "WHITE" ) == 0 )
            White( a, x, y, len );
        
else if( strcmp( s, "TEST" ) == 0 )
            Test( a, x, y, len );
        n
--;
    }


    
return 0;
}


void Black( int a[][ 101 ], int x, int y, int len )
{
    
forint i = x;i < x + len;i++ )
        
forint j = y;j < y + len;j++ )
            a[ i ][ j ] 
= 1;
}


void White( int a[][ 101 ], int x, int y, int len )
{
    
forint i = x;i < x + len;i++ )
        
forint j = y;j < y + len;j++ )
            a[ i ][ j ] 
= 0;
}


void Test( int a[][ 101 ], int x, int y, int len )
{
    
int n = 0;
    
forint i = x;i < x + len;i++ )
        
forint j = y;j < y + len;j++ )
            
if( a[ i ][ j ] == 1 )
                
++n;
    cout
<< n << endl;
}

发表于 @ 2006年11月16日 20:41:00|评论(loading...)|编辑

新一篇: 北大ACM第2418题  | 旧一篇: 北大ACM第1007题

评论

#Run&amp;Run 发表于2008-03-11 20:30:33  IP: 117.51.2.*
超级大SB,居然这样做?!
发表评论  


登录
Csdn Blog version 3.1a
Copyright © 何东付