Best_Project

remove consonants from a string

Jun 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include<string.h>
  3. #include<string>
  4. using namespace std;
  5.  
  6. int main() {
  7.     //code
  8.     int t;cin>>t;
  9.    //sau khi nhập t, có ấn enter--> cần xóa bộ nhớ đệm, không thì enter sẽ vào biến s --> sai
  10.     cin.ignore();
  11.  
  12.     while(t--)
  13.     {
  14.        
  15.         string s;string s1 = "";
  16.         getline(cin,s);
  17.         for(int i = 0;s[i] !='\0';i++)
  18.         {
  19.             if(s[i] == 'U'||s[i]=='E'||s[i]=='O'||s[i]=='A'||s[i]=='I'||
  20.                 s[i]=='u'||s[i]=='e'||s[i]=='o'||s[i]=='a'||s[i]=='i'||s[i] ==' '  )
  21.             {
  22.                 s1+=s[i];
  23.             }
  24.         }
  25.         if (s1 == "") {cout<<"No Vowel"<<endl;}
  26.         else {cout<<s1<<endl;}
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment