#include <bits/stdc++.h>
using namespace std;
int n[30][30];
void init(int horsex,int horsey)
{
int k[9][2]={
{-1,-2},
{-1,+2},
{+1,-2},
{+1,+2},
{-2,-1},
{-2,+1},
{+2,-1},
{+2,+1},
{0, 0}
};
for (int i=0;i<9;i++)
{
n[horsex+5+k[i][0]][horsey+5+k[i][1]]=-1;
}
}
int main()
{
memset(n,0,sizeof(n));
int bx,by;
cin>>bx>>by;
int horsex,horsey;
cin>>horsex>>horsey;
n[5][5]=1;
init(horsex,horsey);
for (int i=5;i<=bx+5;i++)
{
for (int j=5;j<=by+5;j++)
{
if (n[i][j]!=-1)
{
if (n[i-1][j]!=-1)
{
n[i][j]+=n[i-1][j];
}
if (n[i][j-1]!=-1)
{
n[i][j]+=n[i][j-1];
}
}
cout<<setw(5)<<n[i][j];
}
printf("\n");
}
cout<<n[bx+5][by+5];
return 0;
}
啊这。。。 只过了三个样例 (恼)
有大佬帮忙解决吗 HELP!!!