본문 바로가기
PROGRAMMING CODE/C

[BAEKJOON] No.5622 C언어

by daye_ 2021. 10. 18.

다이얼

​if else를 쓰면 가독성이 더 좋을것같긴 하지만,,

 

 

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

int main(){
    char str[16];
    int dial[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9,};
    int sec = 0;
    scanf("%s",str);
    for(int i=0; i<strlen(str); i++){
        sec += dial[str[i]-'A']+1;
    }
    printf("%d\n",sec);
    return 0;
}

'PROGRAMMING CODE > C' 카테고리의 다른 글

[BAEKJOON] No.1712 C언어  (0) 2021.10.19
[BAEKJOON] No.2941 C언어  (0) 2021.10.19
[BAEKJOON] No.2908 C언어  (0) 2021.10.18
[BAEKJOON] No.1152 C언어  (0) 2021.10.18
[BAEKJOON] No.1157 C언어  (0) 2021.10.18