0分求助(cpp)

学术版

fanshuangwei666 @ 2024-11-01 21:42:59

0分求助,快帮帮我```cpp

include<bits/stdc++.h>

using namespace std; const int N=1e3+10; char s[N][N]; int T,n,m,k,x_0,y_0,d_0,ans=1; int vis[N][N]; int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0}; bool Check(int x,int y,int d){ int tx=x+dx[d],ty=y+dy[d]; if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&s[tx][ty]=='.'){ x_0=tx,y_0=ty; return 1; }else{ d_0=(d+1)%4; return 0; } } void Input(){ cin>>n>>m>>k; cin>>x_0>>y_0>>d_0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>s[i][j]; } } } int main(){ cin>>T; for(int i=1;i<=T;i++) Input(); vis[x_0][y_0]=1; while(k--){ if(Check(x_0,y_0,d_0)){ if(vis[x_0][y_0]==0){ ans++; vis[x_0][y_0]=1; } } } cout<<ans<<endl; ans=1; memset(vis,0,sizeof(vis)); return 0; }


by JiangHaoXuan15 @ 2024-11-01 21:48:03

@fanshuangwei666 哪道题啊?


|