Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string word, vowels = "aeiouyAEIOUY", strongWord = "";
- getline(cin, word);
- double strongSum = 0;
- while (word != "End of words") {
- double wordSum = 0;
- for (int i = 0; i < word.length(); i++) {
- wordSum += word[i];
- }
- if (vowels.find(word[0]) != -1){
- wordSum *= word.length();
- }
- else {
- wordSum /= word.length();
- }
- if (wordSum > strongSum) {
- strongWord = word;
- strongSum = wordSum;
- }
- getline(cin, word);
- }
- cout << "The most powerful word is " << strongWord << " - " << (int)strongSum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement