Write a program that will take a string S as input and will remove vowels a, e, i, o, u (in lower or upper case) from the string. If two or more than two vowels occur together, then the program shall ignore all of those vowels.
#include <bits/stdc++.h>
#define rep(a, b, c) for (int a = b; a < c; a++)
#define vi vector<int>
using namespace std;
int main()
{
bool yo;
yo = false;
int he;
string s = "Heel";
int i = 0;
// cin >> s;
while (i < s.length())
{
if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O' || s[i] == 'U')
{
if (s[i + 1] == 'a' || s[i + 1] == 'e' || s[i + 1] == 'i' || s[i + 1] == 'o' || s[i + 1] == 'u' || s[i + 1] == 'A' || s[i + 1] == 'E' || s[i + 1] == 'I' || s[i + 1] == 'O' || s[i + 1] == 'U')
{
while (s[he + 1] != 'a' || s[he + 1] != 'e' || s[he + 1] != 'i' || s[he + 1] != 'o' || s[he + 1] != 'u' || s[he + 1] != 'A' || s[he + 1] != 'E' || s[he + 1] != 'I' || s[he + 1] != 'O' || s[he + 1] != 'U' || he < s.length())
{
he++;
}
}
else
{
s.erase(remove(s.begin(), s.end(), s[i]), s.end());
}
i = i + he;
he = 0;
}
else
{
i++;
}
}
cout << s;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire