#include <iostream>
using namespace std;
class Vector2
{
public:
int x;
int y;
public:
Vector2()
{
x = 0;
y = 0;
}
Vector2(int x,int y)
{
this->x = x;
this->y = y;
}
bool operator ==(Vector2* des)
{
return des->x == this->x && des->y == this->y ? true : false;
}
~Vector2()
{
}
};
Vector2** getPosition(Vector2* ma);
int getPath(Vector2 current, Vector2** pos, Vector2* dir);
int main()
{
Vector2* b = new Vector2();
Vector2* ma = new Vector2();
cin >> b->x >> b->y >> ma->x >> ma->y;
Vector2* bin = new Vector2(0, 0);
Vector2** pos = getPosition(ma);
//cout << ( * pos)[0].x;
Vector2 a;
a.x = 0;
a.y = 0;
int count = 0;
long long int path[21][21] = { 0 };
for (int i = 0; i <= b->x; i++)
{
for (int j = 0; j <= b->y; j++)
{
Vector2 current;
current.x = i;
current.y = j;
for (int k = 0; k < 9; k++)
{
Vector2* p = new Vector2((*pos)[k].x, (*pos)[k].y);
if (current == p)//在阻碍点
{
current.x = -1;
break;
}
}
if (current.x != -1)
{
if (i == 0 || j == 0)
{
path[i][j] = 1;
}
else
{
path[i][j] = path[i - 1][j] + path[i][j - 1];
}
}
}
}
cout << path[b->x][b->y];
//cout << getPath(a, pos, b);
return 0;
}
Vector2(* pos) = new (Vector2[9]);
Vector2** getPosition(Vector2* ma)
{
//前左 前右
pos[0].x = ma->x - 1;
pos[0].y = ma->y - 2;
pos[1].x = ma->x + 1;
pos[1].y = ma->y - 2;
//后左 后右
pos[2].x = ma->x - 1;
pos[2].y = ma->y + 2;
pos[3].x = ma->x + 1;
pos[3].y = ma->y + 2;
//左前 左后
pos[4].x = ma->x - 2;
pos[4].y = ma->y - 1;
pos[5].x = ma->x - 2;
pos[5].y = ma->y + 1;
//右前 右后
pos[6].x = ma->x + 2;
pos[6].y = ma->y - 1;
pos[7].x = ma->x + 2;
pos[7].y = ma->y + 1;
pos[8] = *ma;
return &pos;
}
不知道为什么,求助大佬。