Submission

Status:
P-P-PP-P-P

Score: 60

User: Buktep

Problemset: ลูกเต๋า (2566)

Language: c

Time: 0.001 second

Submitted On: 2024-10-16 19:53:24

#include <stdio.h>

int main()
{
    char input[4];
    int die[3];
    char p[5][4] =
    {
        "   ",
        "*  ",
        " * ",
        "  *",
        "* *"
    };

    scanf("%s", input);
    for (int i = 0; i < 3; i++)
    {
        die[i] = input[i] - '0'; //char -> int
    }

    for (int row = 0; row < 3; row++)
    {
        for (int d = 0; d < 3; d++)
        {
            int num = die[d];
            if (num == 1)
            {
                if (row == 1)
                    printf(" * ");
                else
                    printf("   ");
            }
            else if (num == 2)
            {
                if (row == 0)
                    printf("%s", p[1]);
                else if (row == 2)
                    printf("%s", p[3]);
                else
                    printf("%s", p[0]);
            }
            else if (num == 3)
            {
                if (row == 0)
                    printf("%s", p[1]);
                else if (row == 1)
                    printf("%s", p[2]);
                else
                    printf("%s", p[3]);
            }
            else if (num == 4)
            {
                if (row == 0 || row == 2)
                    printf("%s", p[4]);
                else
                    printf("%s", p[0]);
            }
            else if (num == 5)
            {
                if (row == 0 || row == 2)
                    printf("%s", p[4]);
                else
                    printf("%s", p[2]);
            }
            else if (num == 6)
            {
                if (row == 0 || row == 2)
                    printf("%s", p[4]);
                else
                    printf("%s", p[4]);
            }
            else if (num < 1 || num > 6)
            {
                if (row == 2)
                    printf("___");
                else
                    printf("   ");
            }
            printf(" ");
        }
        printf("\n");
    }

    return (0);
}