求求大佬这个为什么不对啊
查看原帖
求求大佬这个为什么不对啊
1642413
zhang_126楼主2025/1/14 17:08
#include<stdio.h>
#include<math.h>
int main()
{
	int str[100][100],n,m,c1,c2;
	scanf("%d %d %d %d",&n,&m,&c1,&c2);
	int i,j;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			str[i][j]=1;
			if(i==c1&&j==c2)
			str[i][j]={0};
			if((i==c1-1||i==c1+1)&&(j==c2-2||j==c2+2))
			str[i][j]={0};
			if((i==c1-2||i==c1+2)&&(j==c2+1||j==c2-1))
			str[i][j]=0;
		}
	}
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(i==0||j==0)
			if(str[i][j]==0)
			{
				int newi=i,newj=j;
				if(i==0)
				for(;j<=m;j++)
				str[i][j]=0;
				else
				for(;i<=n;i++)
				str[i][j]=0;
				i=newi,j=newj;
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(str[i][j]==0)continue;
			str[i][j]=str[i-1][j]+str[i][j-1];
		}
	}
	printf("%d",str[m][n]);
	return 0;
}
2025/1/14 17:08
加载中...