Advertisement
Riposati

Untitled

Jun 30th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cctype>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. long long mapeiaLetras(string frase){
  8.  
  9.     long long tot = 0;
  10.     int i;
  11.  
  12.     for(i=0;i<frase.length();i++){
  13.  
  14.         if(frase[i]=='a' || frase[i]=='d' || frase[i]=='g' || frase[i]=='j'
  15.            || frase[i]=='m' || frase[i]=='p' || frase[i]=='t' || frase[i]=='w'
  16.            || frase[i]==' '){
  17.             tot+=1;
  18.         }
  19.  
  20.         if(frase[i]=='b' || frase[i]=='e' || frase[i]=='h' || frase[i]=='k'||
  21.            frase[i]=='n' || frase[i]=='q' || frase[i]=='u' || frase[i]=='x'){
  22.             tot+=2;
  23.         }
  24.  
  25.         if(frase[i]=='c' || frase[i]=='f' || frase[i]=='i' || frase[i]=='l'||
  26.            frase[i]=='o' || frase[i]=='r' || frase[i]=='v' || frase[i]=='y'){
  27.             tot+=3;
  28.         }
  29.  
  30.         if(frase[i]=='s' || frase[i]=='z'){
  31.             tot+=4;
  32.         }
  33.     }
  34.  
  35.     return tot;
  36. }
  37.  
  38. int main()
  39. {
  40.     string frase;
  41.     int t,caso=1;
  42.  
  43.     cin>>t;
  44.     getchar();
  45.  
  46.     while(t--){
  47.  
  48.  
  49.         getline(cin,frase);
  50.  
  51.         long long resp = mapeiaLetras(frase);
  52.  
  53.         printf("Case #%d: %llu\n",caso,resp);
  54.         caso++;
  55.     }
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement