模拟题。。。 #include <iostream> #include <vector> #include <stack> #include <queue> #include <iterator> #include <numeric> #include <string> #include <algorithm> #include <cmath> #include <cstdlib> #include <sstream> using namespace std; int a[101][101]; int main() { int n,m; cin>>n>>m; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>a[i][j]; } } char ch; int x,y,k; cin>>x>>y>>ch>>k; for(int i=0;i<k;i++) { if(a[x][y]==0) { if(ch=='L') { ch='D'; a[x][y]=1; x++; } else if(ch=='U') { ch='L'; a[x][y]=1; y--; } else if(ch=='D') { ch='R'; a[x][y]=1; y++; } else if(ch=='R') { ch='U'; a[x][y]=1; x--; } } else if(a[x][y]==1) { if(ch=='L') { ch='U'; a[x][y]=0; x--; } else if(ch=='U') { ch='R'; a[x][y]=0; y++; } else if(ch=='D') { ch='L'; a[x][y]=0; y--; } else if(ch=='R') { ch='D'; a[x][y]=0; x++; } } } cout<<x<<" "<<y<<endl; return 0; }
解题思路:
注意事项:
参考代码:
0.0分
0 人评分
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)万恶的long long浏览:901 |
小九九 (C语言描述,不看要求真坑爹)浏览:998 |
演讲大赛评分 (C语言代码)浏览:1686 |
字符逆序 (C语言代码)浏览:668 |
筛排处理 (C语言代码)浏览:821 |
1162答案错误,为什么浏览:696 |
小O的图案 (C语言代码)浏览:969 |
C语言训练-排序问题<1> (C语言代码)浏览:363 |
简单的a+b (C语言代码)浏览:491 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:523 |