rqn 137 找试场(模拟)
来源:互联网 发布:easing.js 编辑:程序博客网 时间:2024/04/30 23:11
题目连接:http://www.rqnoj.cn/Problem_137.html
解题思路:模拟,水题一道,看代码。
#include <stdio.h>#include <string.h>const int N = 10;const int r[] = {1, 2, 3, 0};const int l[] = {3, 0, 1, 2};int n;char order[N];int main() { while (scanf("%d", &n) == 1) {int x = 0, y = 0, dir = 0, flag = 0;for (int i = 0; i < n; i++) { scanf("%s", order); if (strcmp(order, "left") == 0)dir = l[dir]; else if (strcmp(order, "right") == 0)dir = r[dir]; else {int step;flag = 1;sscanf(order, "%d", &step);if (dir == 0) y += step;else if (dir == 1) x += step;else if (dir == 2) y -= step;else if (dir == 3) x -= step;printf("(%d,%d)\n", x, y); }}if (flag == 0) printf("(0,0)\n"); } return 0;}
- rqn 137 找试场(模拟)
- [RQNOJ]137找试场
- 【2016.10.7NOIP普及模拟】找试场
- 【字符串处理】【RQNOJ】找试场
- rqn 51 乒乓球(字符串处理)
- rqn 144 伯虎点秋香(字符串处理)
- rqn 224 手机(常量数组)
- rqn 399 笨小猴(字符串处理)
- PID2 / 开心的金明(rqn)
- cf(找规律,模拟)
- HDU2147(模拟找规律)
- 找位置(简单模拟)
- FZU1062(找规律+模拟)
- 找试场——世上无难题,只要肯思考_耀晨SYW
- rqn 516 多项式输出(字符串输出处理)
- poj1029(找假硬币)模拟
- Harmonic Number (II)(模拟找规律)
- hdu 2082 找单词(模拟)
- oracle数据库同步,100万数据秒级插入
- Oracle创建表空间、创建用户以及授权、查看权限
- iOS -- 图形绘制(全)
- [Tjoi2013]攻击装置 bzoj3175 独立集与特例
- 国家气象局免费天气预报接口API
- rqn 137 找试场(模拟)
- Shell编程学习---第五篇:Shell的输入和输出
- IOS登陆+注册+抽奖+排行榜
- 网络流 dicnic sap 2种算法详细解释 以及例题POJ1459
- POJ 1192 限制条件最短路
- ubuntu中关闭防火墙
- 【C++沉思录】构造函数与析构函数的出现时机
- Web版RSS阅读器(四)——定制自己的Rss解析库myrsslib4j
- C++隐藏任务栏和桌面