슈도코드 2019. 10. 18. 23:29

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

int main(void)
{
	char str[16] = { 0 }; // 배열 생성
	int time[] = { 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6,
		7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10 }; //알파벳에 따른 시간
	int res = 0;

	scanf("%s", str); 

	for (int i = 0; i < strlen(str); i++)
		res += time[str[i] - 'A'];

	printf("%d \n", res);
	return 0;
}
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	char str[16] = { 0 };
	int time[] = { 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6,
		7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10 };
	int res = 0;

	cin >> str;
	
	for (int i = 0; i < strlen(str); i++)
		res += time[str[i] - 'A'];

	cout << res << '\n';
	return 0;
}