Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
318 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* @author: imkaka | ||
* @date: 25/12/2018 | ||
*/ | ||
|
||
#include <iostream> | ||
#include <algorithm> | ||
using namespace std; | ||
int main() | ||
{ | ||
int count = 0; | ||
string str; | ||
cout << "/* ===== Number of Vowels ===== */" << endl; | ||
cout << "\nEnter the string: "; | ||
cin >> str; | ||
|
||
// transform(str.begin(), str.end(), str.begin(), ::tolower); | ||
|
||
for (int i = 0; i < str.size(); i++) | ||
{ | ||
if ( | ||
tolower(str[i]) == 'a' || | ||
tolower(str[i]) == 'e' || | ||
tolower(str[i]) == 'i' || | ||
tolower(str[i]) == 'o' || | ||
tolower(str[i]) == 'u') | ||
{ | ||
count++; | ||
} | ||
} | ||
// Print the result | ||
cout<<"Number of vowels in \""<<str<<"\" = "<<count<<endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* @author : imkaka | ||
* @date : 25/12.2018 | ||
*/ | ||
|
||
|
||
#include <iostream> | ||
#include <algorithm> | ||
#include <vector> | ||
|
||
using namespace std; | ||
int main() | ||
{ | ||
string str; | ||
cout << "Enter the string: "; | ||
cin >> str; | ||
|
||
int max_count = -1; | ||
char label; | ||
for (int i = 0; i < str.size(); ++i) | ||
{ | ||
int current_count = count(str.begin(), str.end(), str[i]); | ||
if (current_count > max_count) | ||
{ | ||
max_count = current_count; | ||
label = str[i]; | ||
} | ||
} | ||
cout << "'" << (char)label << "' has MAX " << max_count << " occurences in " << str << endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
=begin | ||
@author: aaditkamat | ||
@date: 25/12/2018 | ||
=end | ||
def count_vowels(str) | ||
if str === nil or not str.class === String | ||
-1 | ||
end | ||
ctr = 0 | ||
str.downcase! | ||
vowels = ['a', 'e', 'i', 'o', 'u'] | ||
vowels.each do |vowel| | ||
ctr += str.count(vowel) | ||
end | ||
ctr | ||
end | ||
|
||
print "Enter a string: " | ||
str = gets | ||
str.chomp! | ||
puts "The number of vowels in #{str} is : #{count_vowels(str)}" |
Oops, something went wrong.