| ||||||||||
| 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 | |||||||||
垃圾题目,奇怪的问题我用函数就过,但是把函数的操作写在main()里面,就WA,郁闷,什么垃圾啊!!!
#include <iostream>
#include <memory>
#include <stdio.h>
#include <string.h>
using namespace std;
//#define N 100
int table[100][100];
void WHITE(int x,int y,int L)
{
for(int i=x-1;i<x+L-1;i++)
for(int j=y-1;j<y+L-1;j++)
table[i][j]=0;
}
void BLACK(int x,int y,int L)
{
for(int i=x-1;i<x+L-1;i++)
for(int j=y-1;j<y+L-1;j++)
table[i][j]=1;
}
void TEST(int x,int y,int L)
{ int count=0;
for(int i=x-1;i<x+L-1;i++)
for(int j=y-1;j<y+L-1;j++)
if(table[i][j]==1)
count++;
cout<<count<<endl;
}
int main()
{
char command[8];
int x,y,l;
int test_cases;
//cin >>test_cases;
scanf("%d",&test_cases);
/*0表示white*/
memset(table,0,sizeof(table));
//memset(command,0,10000);
int k,i,j;
for(k=0;k<test_cases;k++)
{
scanf("%s %d %d %d",command,&x,&y,&l);
if (strcmp(command,"WHITE") == 0)
{
//for (i=x-1;i<x+l-1;i++)
//{
// for (j=y-1;j<y+l-1;j++)
// {
// table[i][j] = 0;
// }
//}
WHITE(x,y,l);
}
else if(strcmp(command,"BLACK") == 0)
{
//for (i=x-1;i<x+l-1;i++)
//{
// for (j=y-1;j<y+l-1;j++)
// {
// table[i][j] = 1;
// }
//}
BLACK(x,y,l);
}
else if (strcmp(command,"TEST") == 0)
{
//int count = 0;
//for (i=x-1;i<y+l-1;i++)
//{
// for (j=y-1;j<y+l-1;j++)
// {
// if(table[i][j] == 1)
// {
// count++;
// }
// }
//}
TEST(x,y,l);
//cout <<count<<endl;
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator