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 |
水题1A,贴个代码#include<cstdio> int map[101][101]; void black(int x,int y,int l) { for(int i=x;i<=x+l-1;i++) { for(int j=y;j<=y+l-1;j++) { map[i][j]=1; } } } void white(int x,int y,int l) { for(int i=x;i<=x+l-1;i++) { for(int j=y;j<=y+l-1;j++) { map[i][j]=0; } } } int test(int x,int y,int l) { int ans=0; for(int i=x;i<=x+l-1;i++) { for(int j=y;j<=y+l-1;j++) { if(map[i][j]==1) ans++; } } return ans; } int main() { int x=0,y=0,l=0; int i=0,ans=0,t=0; char command[6]={""}; scanf("%d",&t); while(t--) { scanf("%s%d%d%d",command,&x,&y,&l); if(command[0]=='B') black(x,y,l); else if(command[0]=='W') white(x,y,l); else { ans=test(x,y,l); printf("%d\n",ans); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator