Questions B
Questions B
#include <bits/stdc++.h>
using namespace std;
int main()
{
string str;
getline(cin, str);
map<char,int>mp;
for(int i=0;i<str.length();i++){
mp[tolower(str[i])]++;
}
for(auto x:mp){
// cout<<x.first<<" "<<x.second<<endl;
if(x.first=='a'||x.first=='e'||x.first=='i'||x.first
=='o'||x.first=='u'){
if(mp.find(char(x.first+1))!=mp.end()){
// cout<<char(x.first+1)<<endl;
mp[char(x.first+1)]+=mp[x.first];
}
else{
mp[char(x.first+1)]=x.second;
}
}
}
int mx=INT_MIN;
for(auto x:mp){
// cout<<x.first<<" "<<x.second<<endl;
mx=max(mx,x.second);
}
char ch;
for(auto x:mp){
if(mx==x.second &&
!(x.first=='a'||x.first=='e'||x.first=='i'||x.first=='o'||x.
first=='u')){
ch=x.first;
}
}
cout<<ch<<endl;
return 0;
}
2. OUTPUT :
Windows PowerShell
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS F:\c++>