5026

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

// 문자열 숫자 정수 문자로 치환하기
int strToInt(char *num, int start, int end){
    int sum = 0;
    int v = 1;
    for(int i = end; i >= start; i--, v*=10){
        sum += (num[i] - 48) * v;
    } 
    return sum;
}

int main(void){
    // 테스트 케이스 입력
    int test_case = 0;
    scanf("%d", &test_case);

    for(int i = 0; i < test_case; i++){
        // 문제 입력
        char problem[10] = {0};
        getchar();
        scanf("%s", problem);

        int len = strlen(problem);
        int j = 0;
        for(j; j < len; j++){
            // 숫자 문제 일 경우
            if(problem[j] == '+'){
                break;
            }
        }

        if(j != len){
            // + 앞 숫자 + 뒷 숫자 a,b에 넣기
            int a = strToInt(problem, 0, j-1); 
            int b = strToInt(problem, j+1, len-1);

            // a+b 출력
            printf("%d\n", a+b);
        }
        else{
            // P=NP 문제일 경우 스킾
            printf("skipped\n");
        }
    }
        
    return 0;
}

+ Recent posts