zoukankan      html  css  js  c++  java
  • 完美笔试第一题

    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;
    
    }
  • 相关阅读:
    http 学习 1-1 chapter1-HTTP概述
    2048 游戏实现原理
    safari 日期对象新建new Date( timeStr ) 参数TimeStr格式
    js
    js 常见弹出框学习
    JS引入CSS文件
    JAVA 遍历文件夹下的所有文件(递归调用和非递归调用)
    java复制文件 转
    Map键值对,一种思路
    写入excel表格数据
  • 原文地址:https://www.cnblogs.com/wdan2016/p/6641787.html
Copyright © 2011-2022 走看看