#include<stdio.h> #define MAX 100 char dir[5] = {'U', 'R', 'D', 'L'}; int color[MAX][MAX]; int m, n; int x, y, dir_tmp, step; int getNumOfDir(char d) { if (d == 'U') return 0; if (d == 'R') return 1; if (d == 'D') return 2; if (d == 'L') return 3; } void Move()//前进 { if(dir_tmp == 'U') { if(x != 0) { x -= 1; // printf("%c x = %d, y = %d\n",dir_tmp, x, y);//debug return; } } if(dir_tmp == 'R') { if(y != n-1) { y += 1; // printf("%c x = %d, y = %d\n",dir_tmp, x, y);//debug return; } } if(dir_tmp == 'D') { if (x != m-1) { x += 1; // printf("%c x = %d, y = %d\n",dir_tmp, x, y);//debug return ; } } if(dir_tmp == 'L') { if(y != 0) { y -= 1; // printf("%c x = %d, y = %d\n",dir_tmp, x, y);//debug return; } } } int main() { int i, j; int getN; scanf("%d%d", &m, &n); for (i = 0; i < m; ++i) for (j = 0; j < n; ++j) { scanf("%d", &color[i][j]); } scanf("%d %d %c %d", &x, &y, &dir_tmp, &step); // printf("%d %d %c %d\n", x, y, dir_tmp, step);//debug while(step--) { if(color[x][y] == 1) { color[x][y] = 0; getN = getNumOfDir(dir_tmp) + 5; dir_tmp = dir[getN%4]; // printf("dir_tmp = %c\ngetN = %d\n", dir_tmp, getN%4);//debug Move(); } else { color[x][y] = 1; getN = getNumOfDir(dir_tmp) + 3; dir_tmp = dir[getN%4]; // printf("dir_tmp = %c\ngetN = %d\n", dir_tmp, getN%4);//debug Move(); } } printf("%d %d\n", x, y); return 0; }
0.0分
0 人评分
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1267 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:769 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:642 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:583 |
矩阵加法 (C语言代码)浏览:1768 |
Hello, world! (C语言代码)浏览:766 |
DNA (C语言代码)浏览:798 |
格式化数据输出 (C语言代码)浏览:882 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:592 |
A+B for Input-Output Practice (I) (C语言代码)浏览:599 |