歸去來兮

Jeanny發表於2024-04-13
// #include <bits/stdc++.h>
#include <stdc++.h>
#define ll long long
using namespace std;
int sx, sy, tx, ty;
//下右 - 
int main() {
    cin >> sx >> sy >> tx >> ty;
    if(tx >= sx && ty <= sy){// 右下
        for(int i = 1; i <= (ty - sy); i++) cout<<"D "; for(int i = 1; i <= (tx - sx); i++) cout<<"L ";
        cout<<"D"<<endl; for(int i = 1; i <= (tx - sx + 1); i++) cout<<"L "; for(int i = 1; i <= sy - ty + 1; i++) cout<<"U "; cout<<"R"<<endl;
        cout<<"R "; for(int i = 1; i <= sy - ty -1; i++) cout<<"D "; for(int i = 1; i <= tx - sx - 1; i++) cout<<"R "; cout<<"D"<<endl;
        cout<<"R "; cout<<"U U ";
        for(int i = 1; i <= tx - sx - 1; i++) cout<<"L "; for(int i = 1; i <= sy - ty - 1; i++) cout<<"U ";
        for(int i = 1; i <= 2; i++) cout<<"L "; cout<<"D"<<endl;
    }
    return 0;
}
/*



         *  . . .

*/



// #include <bits/stdc++.h>
#include <stdc++.h>
#define ll long long
using namespace std;
int sx, sy, tx, ty;
//下右 - 
void f1(int h, char d1, int s, char d2){
    for(int i = 1; i <= h; i++) cout<<d1; 
    for(int i = 1; i <= s; i++) cout<<d2;
}
int main() {
    cin >> sx >> sy >> tx >> ty;
    int leny = abs(ty - sy); int lenx = abs(tx - sx);
  
        cout<<"D"; 
        f1(lenx+1, 'R', leny+1, 'U');
        cout<<"L";

        f1(leny, 'D', lenx, 'L');
       

        cout<<"L"; cout<<"UU";
        f1(lenx-1, 'R', leny-1, 'U');
        cout<<"RR"; cout<<"D";

        cout<<"L"; 
        f1(leny-1, 'D', lenx-1, 'L');
        cout<<"D";
    
    return 0;
}
/*
       
       *


        .  .  .  *  .
0 -3 3 -7
3 -7 0 -3 
1 2 4 5
4 5 1 2
*/


相關文章