完美笔试第一题
2017-03-29 21:07
302 查看
include "stdafx.h"
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<mutex> #include<stack> #include<iomanip> #include<math.h> using namespace std; int main() { int w, h, x, n; int pi = 3.1415926; while (cin>>w>>h>>x>>n) { //判断每次弹出的小球是右侧还是左侧 //记录正在操作的边 int left = 0; int right = 0; int up = 0; int down = 0; while (n!=0) { n--; while (down!=1) { if ((w - x) == h) { //cout << x << " " << endl; down = 1; left = 0; right = 0; up = 0; } else if ((w - x) < h) //碰到右面 { if (down == 1) { down = 0; left = 0; right = 1; up = 0; } else if (right==1) { down = 0; left = 0; right = 0; up = 1; } else if (up == 1) { down = 0; left = 1; right = 0; up = 0; } else { down = 1; left = 0; right = 0; up = 0; } x = w - x; int temp = w; w = h; h = temp; } else//碰到上面面 { if (down == 1) { down = 0; left = 0; right = 0; up = 1; } else if (right == 1) { down = 0; left = 1; right = 0; up = 0; } else if (up == 1) { down = 1; left = 0; right = 0; up = 0; } else { down = 0; left = 0; right = 1; up = 0; } x = x + h; int temp = w; w = h; h = temp; } } if (n != 0) { cout << x<<" "; } } cout <<x; } return 0; }
相关文章推荐
- 360笔试编程题之第一题
- 滴滴笔试编程题第一题
- 【hihocoder#1341】(微软探星夏令营在线技术笔试第一题)
- My Love太经典了,完美的作品,英国排行第一+西城成名曲
- 人生第一笔试加面试 SAP胜略
- 2017年亚信笔试测试第一题:判断字符串是否可以连接
- 微软夏令营笔试测验第一题 Array Partition
- 拼多多笔试题第一题,大数相乘
- 完美洗牌算法(2013年UC校招笔试、2016阿里实习生笔试)
- 腾讯2014春季实习生招聘 笔试题目 第一批次
- 腾讯2017年校园招聘笔试题第一题
- [百度2016实习 在线笔试 编程第一题 度度熊 C语言]
- 2017微软秋季校园招聘在线编程笔试(第一题)
- 2015小米笔试第一题
- 腾讯,迅雷,完美等公司的一些笔试题整理
- 微软2016年4月实习生笔试第一题-font size题解
- 搜狐2010校园招聘第一站北邮笔试题(转) 以及 本人做的部分答案
- Legendary Items-微软2017实习生笔试第一题
- 合肥市第二十三届“讯飞”杯笔试第一题
- 微软2016校园招聘在线笔试题目-第一题 Magic Box