Codeforces --- string task


Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
  • deletes all the vowels,
  • inserts a character "." before each consonant,
  • replaces all uppercase consonants with corresponding lowercase ones.
Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.
Help Petya cope with this easy task.
Input
The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.
Output
Print the resulting string. It is guaranteed that this string is not empty.
Examples
input
tour
output
.t.r
input
Codeforces
output
.c.d.f.r.c.s
input
aBAcAba
output
.b.c.b



  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int main()
  5. {
  6. int i,j,k,iLength,l;
  7. string sIn;
  8. char cOut[301] = {'0'};
  9. bool bCheck;
  10. char cList[6] = {'a','e','i','o','u','y'};
  11. cin >> sIn;
  12. iLength = sIn.length();
  13. = 0;
  14. cOut[0] = '.';
  15. = 1;
  16. while ( i<iLength )
  17.     {
  18.     bCheck = 0;
  19.     if ( sIn[i] > 64 && sIn[i] < 91 )  
  20.         sIn[i] = sIn[i] + 32;
  21.     for ( k=0 ; k<6 ; k++ )
  22.         {
  23.         if ( sIn[i] == cList[k] )
  24.             bCheck = 1;
  25.         }  
  26.     if ( bCheck == 0 )
  27.         {
  28.         cOut[j] = sIn[i];
  29.         cOut[j+1] = '.';
  30.         j=j+2; 
  31.         }
  32.     i++;   
  33.     }
  34.     //cOut[j-1] ='P';
  35. //  cout << i<<" " <<j <<endl;
  36. for (l=0 ;l<j-1 ;l++)
  37.     cout << cOut[l] ;
  38. if ( j>1)
  39. cout << endl;      
  40. }












留言

這個網誌中的熱門文章

Uva 674 ---- coin change

codeforces 271A --- beautiful year