Submission

Status:
------Px--

Score: 10

User: foldnut

Problemset: นักเดินทาง

Language: c

Time: 0.001 second

Submitted On: 2024-09-26 16:52:15

#include<stdio.h>
#include<math.h>
#include<string.h>

void main(){
    char moveset[52];
    char a[52] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    scanf("%s",moveset);
    /*Length & Height*/
    int lenght = 0;
    int height = 0;
    for(int i = 0;i<52;i++){
        if(moveset[i] == 'R'){
            lenght++;
        }
        else if(moveset[i] == 'D'){
            height++;
        }
    }
    char chart[lenght][height];
    ///////////////////////////////////
    for(int i = 0;i<height;i++){
        for(int j = 0;j<=lenght;j++){
            chart[i][j]='.';
        }
    }
    int x = 0;
    int y = 0;
    chart[0][0] = a[0];
    for(int i = 1;i<52;i++){
        if(moveset[i] == 'D'){
            y++;
        }
        else if(moveset[i] == 'U'){
            y--;
        }
        else if(moveset[i] == 'L'){
            x--;
        }
        else if(moveset[i] == 'R'){
            x++;
        }
        else{
            break;
        }
        chart[x][y] = a[i];
    }
    for(int i = 0;i<height;i++){
        for(int j = 0;j<=lenght;j++){
            printf("%c",chart[j][i]);
        }
        printf("\n");
    }
}