zoukankan      html  css  js  c++  java
  • POJ 1656

     1 #include<iostream>//chengdacaizi  08 .11. 12
     2 #include<string>
     3 using namespace std;
     4 int array[101][101]={0};
     5 int main()
     6 {
     7     void white(int x,int y,int l);
     8     void black(int x,int y,int l);
     9     void test(int x,int y,int l);
    10     string s;
    11     int x,y,l;
    12     int num;
    13     cin>>num;
    14     while(num--){
    15     cin>>s;
    16     cin>>x;
    17     cin>>y;
    18     cin>>l;
    19     if(s=="WHITE")
    20         white(x,y,l);
    21     else if(s=="BLACK")
    22         black(x,y,l);
    23     else if(s=="TEST")
    24         test(x,y,l);
    25     }
    26     return 0;
    27     
    28 }
    29 void white(int x,int y,int l)
    30 {
    31     int i;
    32     int j;
    33     for(i=x;i<=x+l-1;i++)
    34         for(j=y;j<=y+l-1;j++)
    35         {
    36         array[i][j]=0;
    37         }
    38 }
    39 void black(int x,int y,int l)
    40 {
    41     int i;
    42     int j;
    43     for(i=x;i<=x+l-1;i++)
    44         for(j=y;j<=y+l-1;j++)
    45         {
    46             array[i][j]=1;
    47         }
    48 }
    49 void test(int x,int y,int l)
    50 {
    51     int i;
    52     int j;
    53     int result=0;
    54     for(i=x;i<=x+l-1;i++)
    55         for(j=y;j<=y+l-1;j++)
    56         {
    57             result+=(array[i][j]==1);
    58         }
    59         cout<<result<<endl;
    60 }

    关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

    技术网站地址: vmfor.com

  • 相关阅读:
    48-最长不含重复字符的子字符串
    51-数组中的逆序对
    字符串的排列
    二叉树转链表
    求根
    构造二叉树
    二叉树中序遍历
    反转链表系列
    斐波那契系列
    f.lux
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4566480.html
Copyright © 2011-2022 走看看