模拟题。。。 #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语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:869 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:668 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:1059 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:338 |
简单的for循环浏览:1411 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1162 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:799 |
勾股数 (C语言代码)浏览:800 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:562 |
C语言训练-斐波纳契数列 (C语言代码)浏览:511 |