Last Submissions | ||||||
---|---|---|---|---|---|---|
Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
| discuss492 - | Accepted | C++11 | 1.500 | 0.000 | 7203 | 20 mins ago |
Problem: click 492
Suggest:
My way of doing it is quite simple, which is to maintain 2 variables l, r of 2 for loops. The variable l represents the first position of the word, the variable r represents the position of the end of the word. From these two variables we can test for vowels, or transform strings to form the result.
#include<bits/stdc++.h>
using namespace std;
char a[] = {'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u'};
string s;
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
while(getline(cin, s)){
s+='.';
for(int l=0; s[l]; l++)
if (('A' <= s[l] && s[l] <= 'Z')||('a' <= s[l] && s[l] <= 'z')){
bool ae= false;
for(int i=0; i<10; i++)
if (s[l]==a[i]){
ae= true;
break;
}
if (ae)
for(int r=l; s[r]; r++){
if (('A' <= s[r] && s[r] <= 'Z')||('a' <= s[r] && s[r] <= 'z')) continue;
s.insert(r, "ay");
l= r+2;
break;
}
else
for(int r=l; s[r]; r++){
if (('A' <= s[r] && s[r] <= 'Z')||('a' <= s[r] && s[r] <= 'z')) continue;
string x="";
x+=s[l];
s.insert(r, x);
s.insert(r+1, "ay");
s.erase(l, 1);
l= r+2;
break;
}
}
s.erase(s.size()-1, 1);
cout<<s<<"\n";
}
}
No comments:
Post a Comment