模拟题。。。 #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语言代码)浏览:604 |
剔除相关数 (C语言代码)浏览:1012 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:603 |
【回文数(二)】 (C语言代码)浏览:728 |
大小写转换 (C语言代码)浏览:848 |
程序员的表白 (C语言代码)浏览:657 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:502 |
企业奖金发放 (C语言代码)浏览:2317 |
杨辉三角 (C语言代码)浏览:676 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:553 |