0% found this document useful (0 votes)
10 views2 pages

Questions B

Uploaded by

Shan Kritvik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Questions B

Uploaded by

Shan Kritvik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Question 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

Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS F:\c++> cd "f:\c++\" ; if ($?) { g++ consonent.cpp -o consonent } ; if ($?) { .\consonent }


paragliding

PS F:\c++>

You might also like