1864

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

typedef struct octopusNumber
{
    char shape;
    double num;
}ARR;

int main(void){
    ARR octNumArr[9] = {
        {'-', 0},
        {'\\', 1},
        {'(', 2},
        {'@', 3},
        {'?', 4},
        {'>', 5},
        {'&', 6},
        {'%', 7},
        {'/', -1}};

    char start; 
    int resultCount=0;
    double resultArr[99];
    do{
        // 입력
        char str[8]={0};
        scanf("%s", str);
        // #으로 끝나는지 유무를 확인하기 위함
        start = str[0];

        // 문자열 길이 구하기
        int count = 0;
        while(str[count] != '\0'){
            count ++;
        }

        // 문어 숫자 대입하여 비교 후 결과값 구하기
        double result = 0;
        for(int j = 0; j < count; j++){
            for(int z = 0; z < 9; z++){
                // 현재 문자열의 j번째와 문어 숫자의 z번째의 문자를 비교하여
                // 맞으면 결과값 구하기 
                if(str[j] == octNumArr[z].shape){
                    result += octNumArr[z].num * pow(8, count-1-j);
                } 
            }
        }

        // 결과값 배열에 저장
        resultArr[resultCount] = result;
        resultCount ++;
    }
    while(start != '#');

    // 출력
    for(int k =0; k < resultCount-1; k++){
        // int로 형변환하여 출력
        printf("%d\n", (int)resultArr[k]);
    }
    
    return 0;
}

조만간 struct이랑 math.h  정리를 낋여오겠습니당

+ Recent posts