Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
159 additions
and
7 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; | ||
} |
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