✔ Online Judge

[C++] 백준5622 다이얼

근본없는 개발자 2023. 6. 25. 15:53

#include <iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	char str[16];
	int res = 0;
	cin >> str;

	for (int i = 0; i < 15; i++) {
		if (str[i] == '\0') break;

		if (str[i] <= 'P') res += (str[i] - 'A') / 3 + 3;
		else res += str[i] < 'Z' ? (str[i] - 'Q') / 3 + 8 : 10;
	}
	cout << res << '\n';

	return 0;
}