코딩테스트/C

백준 2908번 상수

호중조 2024. 6. 30. 16:34

 

#include <stdio.h>
#include <string.h>
#define SIZE 3

int main(void)
{
    char S1[SIZE];
    char S2[SIZE];
    char zero = '0';

    int a1;
    int a2;
    a1 = 0;
    a2 = 0;

    char temp;

    scanf("%s %s", &S1, &S2);

    temp = S1[0];
    S1[0] = S1[2];
    S1[2] = temp;

    temp = S2[0];
    S2[0] = S2[2];
    S2[2] = temp;

    for (int i = 0; i < SIZE; i++)
    {
        a1 = (a1 * 10) + (S1[i] - zero);
        a2 = (a2 * 10) + (S2[i] - zero);
    }

    if (a1 >= a2)
    {
        printf("%d\n", a1);
    }
    else
    {
        printf("%d\n", a2);
    }

}