简单的贪心,不过一直追求简单一点再简单一点,所以有点纠结
#include<stdio.h>
#include<stdlib.h>
int main(){
int x,y,i,k,t; char s1[3],s2[3];
while(~scanf("%s",s1)){
scanf("%s",s2);
x=s2[0]-s1[0];
y=s2[1]-s1[1];
k=(x>0?x:-x);
t=(y>0?y:-y);
if(k>=t)printf("%d\n",k);
else printf("%d\n",t);
while(s2[0]!=s1[0]||s2[1]!=s1[1]){
if(s1[0]<s2[0])putchar('R'),s1[0]++;
if(s1[0]>s2[0])putchar('L'),s1[0]--;
if(s1[1]<s2[1])putchar('U'),s1[1]++;
if(s1[1]>s2[1])putchar('D'),s1[1]--;
putchar('\n');
}
}
return 0;
}