JosepRivaille

P27152: The value of the letters

May 14th, 2015
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     int count = 0;
  7.     char c;
  8.     while (cin >> c) {
  9.         if (c == 'a' || c == 'e') count += 1;
  10.         else if (c == 'o' || c == 's') count += 2;
  11.         else if (c == 'd' || c == 'i' || c == 'n' || c == 'r') count += 3;
  12.         else if (c == 'c' || c == 'l' || c == 't' || c == 'u') count += 4;
  13.         else if (c == 'm' || c == 'p') count += 5;
  14.         else if (c == 'k' || c == 'w') count += 7;
  15.         else count += 6;
  16.     }
  17.     cout << count << endl;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment