Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一次AC,贴代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator