蒜头君旅游(c++)

蒜头君旅游(c++)

AC代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("city.in", "r", stdin);
    //freopen("city.out", "w", stdout);
	int xyuan,yyuan,maxx,maxy,num,b;
	char a;
	cin>>maxx>>maxy>>num;
	cin>>xyuan>>yyuan;
	for(int i=0;i<=num-1;i++)
	{
		cin>>a>>b;
		{
		    if(a=='r')
		    {
			    yyuan+=b;
		    }
		    if(a=='l')
		    {
			    yyuan-=b;
		    }
		    if(a=='d')
		    {
			    xyuan-=b;
		    }
		    if(a=='u')
		    {
			    xyuan+=b;
		    }
			{
			    if(yyuan>=maxx) yyuan=maxx;
			    if(yyuan<=0) yyuan=0;
			    if(xyuan>=maxy)	 xyuan=maxy;
			    if(xyuan<=0)	xyuan=0;
		    }
		}
		
	}
	cout<<xyuan<<" "<<yyuan;
	//fclose(stdin);
    //fclose(stdout);
}

 

上一篇:SQLServer实现两个库的字段长度自动更新


下一篇:[HNOI2003]激光炸弹(二维前缀和+大坑点)