| ||||||||||
| 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 | |||||||||
数组开小了1个,应为a[101][101];并且每给数组赋初值In Reply To:为什么不对 Posted by:ye at 2004-12-29 13:18:46 > #include<stdio.h>
> #include<string.h>
> void main()
> {
> int a[100][100];
> char head[20];
> int x,y,l,i,j,t,g,num=0;
> scanf("%d",&t);
> for(g=1;g<=t;g++){
> scanf("%s %d %d %d",head,&x,&y,&l);
> if(head[0]=='B'){
> for(i=x;i<=x+l-1;i++)
> for(j=y;j<=y+l-1;j++)
> a[i][j]=1;
> }
> if(head[0]=='W'){
> for(i=x;i<=x+l-1;i++)
> for(j=y;j<=y+l-1;j++)
> a[i][j]=0;
> }
> if(head[0]=='T'){
> num=0;
> for(i=x;i<=x+l-1;i++){
> for(j=y;j<=y+l-1;j++){
> if(a[i][j]==1)num++;
> }
> }
> printf("%d\n",num);
> }
> }
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator