Skip to content

Commit

Permalink
day4 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-gupta14 authored and MadhavBahl committed Dec 26, 2018
1 parent 8f271d2 commit 3c26214
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
27 changes: 27 additions & 0 deletions day4/C++/day4_part_a.cpp
@@ -0,0 +1,27 @@
/*
* @author : dhruv-gupta14
* @date : 25/12/2018
*/

#include <bits/stdc++.h>
using namespace std;
int main()
{

int count = 0;
string str;
cin >> str;

transform(str.begin(), str.end(), str.begin(), ::tolower);

for (int i = 0; i < str.length(); i++)
{
if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u')
{
count++;
}
}

cout<<count;
return 0;
}
30 changes: 30 additions & 0 deletions day4/C++/day4_part_b.cpp
@@ -0,0 +1,30 @@
/*
* @author : dhruv-gupta14
* @date : 25/12/2018
*/

#include <bits/stdc++.h>
using namespace std;
int main()
{
int count = 0;
string str;
cin >> str;

transform(str.begin(), str.end(), str.begin(), ::tolower);

int cnt1 = 0;
char max;
for (int i = 0; i < str.size(); i++)
{
int cnt2 = std::count(str.begin(), str.end(), str[i]);
if (cnt2 > cnt1)
{
cnt1 = cnt2;
max = str[i];
}
}
cout <<char(max) << "=>" << cnt1;

return 0;
}

0 comments on commit 3c26214

Please sign in to comment.