您的位置:首页 > 其它

cf 3a Shortest path of the king

2015-10-24 18:12 405 查看
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
char c1,c2;
int x1,x2;
cin>>c1>>x1>>c2>>x2;
int a=c2-c1,b=x2-x1;
int ans=max(abs(a),abs(b));
printf("%d\n",ans);
while(a!=0||b!=0)
{
if(a>0)
{
printf("R");
a--;
}
else if(a<0)
{
printf("L");
a++;
}
if(b<0)
{
printf("D");
b++;
}
else if(b>0)
{
printf("U");
b--;
}
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: