string reverseVowels(string s) {
        
        int start = 0;
        int end = s.size() - 1;
        unordered_set<char> vowels({'a', 'e', 'i', 'o', 'u'});

        while(start < end)
        {
            while(start < end && vowels.count(tolower(s[start])) == 0)
            {
                start++;
            }

            while(start < end && vowels.count(tolower(s[end])) == 0)
            {
                end--;
            }

            if (start < end){
                char tmp = s[start];
                s[start] = s[end];
                s[end] = tmp;
            }

            start++;
            end--;
        }

        return s;
    }
Ejemplo n.º 2
0
int main() {
    std::vector<std::string> vowel;
    vowel.push_back("a");
    vowel.push_back("b");
    vowel.push_back("c");
    vowel.push_back("d");
    vowel.push_back("e");
    vowel.push_back("f");

    std::vector<std::string>::iterator k;

//for( k=vowel.begin(); k!=vowel.end();) {
//        if( isVowel( *((*k).c_str()))) // for every letter that is a vowel
//            k = vowel.erase(k);
//        else
//            ++k;
//}

    std::string vowels("aeiouEAIOU");
    k = std::remove_if( vowel.begin(), vowel.end(), isVowel_( vowels));
    vowel.erase( k, vowel.end());  // erases the unspecified values and reduces
                                   // the physical size of the container to match
                                   // its new logical size
    
    return 0;
}
Ejemplo n.º 3
0
void main()
{
clrscr();
int choice;
char ch;
do{clrscr();
cout<<"\n MENU ";
cout<<"\n 1.CREATE";
cout<<"\n 2.DISPLAY";
cout<<"\n 3.NO OF UPPER CASE CHARACTERS ";
cout<<"\n 4.NO OF VOWELS";
cout<<"\n 5.NO OF DIGITS";
cout<<"\n 6.NO OF WORDS";
cout<<"\n 7.NUMBER OF LINES";
cout<<"\n enter ur choice";
cin>>choice;
switch(choice)
{
case 1:create();break;
case 2:display();break;
case 3:uppercase();break;
case 4:vowels();break;
case 5:digits();break;
case 6:words();break;
case 7:lines();break;
default: cout<<"\n wrong choice entered..!!";
}
cout<<"\n do you want to continue...??";
cin>>ch;
}
while(ch=='y'||ch=='Y');
}
int KNewPasswordWidget::KNewPasswordWidgetPrivate::effectivePasswordLength(const QString &password)
{
    enum Category {
        Digit,
        Upper,
        Vowel,
        Consonant,
        Special
    };

    Category previousCategory = Vowel;
    QString vowels(QStringLiteral("aeiou"));
    int count = 0;

    for (int i = 0; i < password.length(); ++i) {
        QChar currentChar = password.at(i);
        if (!password.leftRef(i).contains(currentChar)) {
            Category currentCategory;
            switch (currentChar.category()) {
            case QChar::Letter_Uppercase:
                currentCategory = Upper;
                break;
            case QChar::Letter_Lowercase:
                if (vowels.contains(currentChar)) {
                    currentCategory = Vowel;
                } else {
                    currentCategory = Consonant;
                }
                break;
            case QChar::Number_DecimalDigit:
                currentCategory = Digit;
                break;
            default:
                currentCategory = Special;
                break;
            }
            switch (currentCategory) {
            case Vowel:
                if (previousCategory != Consonant) {
                    ++count;
                }
                break;
            case Consonant:
                if (previousCategory != Vowel) {
                    ++count;
                }
                break;
            default:
                if (previousCategory != currentCategory) {
                    ++count;
                }
                break;
            }
            previousCategory = currentCategory;
        }
    }
    return count;
}
Ejemplo n.º 5
0
int doubles(char *name){
  int i=1;

  while (name[i]!='\0') {
   name[i] = tolower(name[i]);
   i = i + 1;
  }

 i=1;

  while (name[i]!='\0') {
    if (name[i]==name[i+1]){
      name[i] = '0';
    }
      i = i + 1;
    }
  return vowels(name);
}
Ejemplo n.º 6
0
void main()
{
 clrscr();
 ofstream fout("poem.txt",ios::trunc);
 fout<<"if you are not willing to learn,\n "
     <<"No one can help you.\n "
     <<"If you are determined to learn,\n "
     <<"No one can stop you.";
 fout.close();
 int x;
 do
 {
  cout<<"\n1-Display file\n2-lower case to upper case\n3-total character\n4-no of words\n5-Average word size\n6-no of lower case and upper case\n7-vowels\n8-no of words starting with I\n9-no. of lines ending with '.'\n10-exit\n";
  cin>>x;
  switch(x)
  {
   case 1:display();
	  break;
   case 2:lowertoupper();
	  cout<<"\nFile with lower to upper\n";
	  display();
	  break;
   case 3:cout<<"\nNo. of characters="<<char_count();
	  break;
   case 4:cout<<"\nNo. of words="<<wordcount();
	  break;
   case 5:cout<<"\nAverage word size=" <<(float)(char_count())/(float)(wordcount());
	  break;
   case 6:lowercount_uppercount();
	  break;
   case 7:cout<<"\n\nVowels in the file are\n";
	  vowels();
	  break;
   case 8:cout<<"\nNo. of words starting with I=" <<counti();
	  break;
   case 9:cout<<"\nNo. of lines ending with \'.\'=" <<dotcount();
	  break;
   case 10: break;
   default: cout<<"Wrong input\n";
  }
 }while(x!=10);
}