Advertisement
JOHNYTHEWINNER

score from chars in string

Feb 1st, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <string>
  7. int main()
  8. {
  9.     string str;
  10.     getline(cin, str);
  11.     int b = str.length();
  12.     int score=0;
  13.     for (int i = 0; i < b; i++)
  14.     {
  15.         if (str[i] == 'a')
  16.         {
  17.             score = score + 1;
  18.         }
  19.         else if (str[i] == 'e')
  20.         {
  21.             score = score + 2;
  22.         }
  23.         else if (str[i] == 'i')
  24.         {
  25.             score = score + 3;
  26.         }
  27.         else if (str[i] == 'o')
  28.         {
  29.             score = score + 4;
  30.         }
  31.         else if (str[i] == 'u')
  32.         {
  33.             score = score + 5;
  34.         }
  35.     }
  36.     cout << score << endl;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement