蒜头君旅游(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);
}
标签:蒜头,maxy,num,int,maxx,c++,xyuan,yyuan,旅游 来源: https://blog.csdn.net/gyk1303/article/details/122391700