标签:游戏
#include"wz.h"
#include"sts.h"
#define MAX 5
void show(int arr[][MAX])
{
for(int i=0;i<MAX;i++)
{
for(int j=0;j<MAX;j++)
{
cout<<arr[i][j]<< " ";
}
cout<<endl;
}
cout<<endl;
}
void play(int arr[][MAX],int x,int y)
{ arr[x][y] = 1 -arr[x][y];
if(x-1 >= 0) { arr[x-1][y] = 1 - arr[x-1][y];}
if(x+1 <= MAX) { arr[x+1][y] = 1 - arr[x+1][y]; }
if(y-1 >= 0) { arr[x][y-1] = 1 - arr[x][y-1]; }
if(y+1 <= MAX) { arr[x][y+1] = 1 - arr[x][y+1];}
}
void funj(int v[][MAX])
{
play(v,4,0);show(v);
play(v,3,1);show(v);
play(v,0,0);show(v);
play(v,1,1);show(v);
//test9
play(v,0,1);show(v);
play(v,0,2);show(v);
play(v,4,1);show(v);
play(v,4,2);show(v);
}
int main()
{
int v[MAX][MAX] = {0};
int x;
int y;
v[0][3]=1; v[4][3]=1;
show(v);
funj(v);
show(v);
return 0;
}标签:游戏
原文地址:http://sts609.blog.51cto.com/11227442/1758681