Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一次AC,贴代码

Posted by speedcell4 at 2011-03-27 12:40:03 on Problem 1656
#include<iostream>
#include<cstring>
using namespace std;
int a[101][101]={0},t,x,y,l;
char c[10];
int jian(char c[])
{
    if(strcmp(c,"BLACK")==0) return 1;
    if(strcmp(c,"WHITE")==0) return 2;
    if(strcmp(c,"TEST")==0)  return 0;
}
int main()
{
    cin>>t;
    while(t--)
    {
        scanf("%s",c);
        switch(jian(c))
        {
            case 1:
                cin>>x>>y>>l;
                for(int i=0;l-i;i++)
                {
                    for(int j=0;l-j;j++)
                    {
                        a[x+i][y+j]=1;
                    }
                }
                break;
            case 2:
                cin>>x>>y>>l;
                for(int i=0;l-i;i++)
                {
                    for(int j=0;l-j;j++)
                    {
                        a[x+i][y+j]=0;
                    }
                }
                break;
            case 0:
                cin>>x>>y>>l;
                int sum=0;
                for(int i=0;l-i;i++)
                {
                    for(int j=0;l-j;j++)
                    {
                        if(a[x+i][y+j]==1) sum++;
                    }
                }
                cout<<sum<<endl;
                break;
        }
    }
}
        

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator