Created
April 1, 2025 18:51
-
-
Save MahraibFatima/98f19e93ba6ce02352c53021c51529d2 to your computer and use it in GitHub Desktop.
Your task is to determine which message is the most cringeworthy by computing its "cringe score" as follows: Each vowel (a, e, i, o, u — in any case) adds 1 point. Each standalone occurrence of the word "Eid" adds a bonus of 3 points. The message with the highest cringe score wins the championship. If there’s a tie, pick the one that appears fir…
This file contains hidden or 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
// Example program | |
#include <iostream> | |
#include<vector> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
int no_of_eid_messages=0; | |
cout<<"Enter number of eid messages: "; | |
cin>>no_of_eid_messages; | |
cout<<"Enter Eid messages: "<<endl; | |
vector<string> eid_messages;// vect of size 'n' | |
//taking input of eid msgs | |
cin.ignore(); | |
for(int i=0; i<no_of_eid_messages; ++i){ | |
string messageVar; | |
getline(cin, messageVar); | |
eid_messages.push_back(messageVar); | |
} | |
//variable to store comp | |
int maxi=-1; | |
string most_cringe=""; | |
//outerloop | |
for(int i=0; i<eid_messages.size(); ++i){ | |
//variables to stroe temp comp | |
string eid_msg= eid_messages[i]; | |
string word=""; | |
int count= 0; | |
//inner loop | |
for(int j=0; j<eid_msg.size(); ++j){ | |
word += eid_msg[j]; | |
if(eid_msg[j] == ' ' && word == "Eid"){ | |
count += 1; | |
word= ""; | |
} | |
if(eid_msg[j] == 'a' || eid_msg[j] == 'e' || eid_msg[j] == 'i' || eid_msg[j] == 'o' || eid_msg[j] == 'u' | |
|| eid_msg[j] == 'A' || eid_msg[j] == 'E' || eid_msg[j] == 'I' || eid_msg[j] == 'O' || eid_msg[j] == 'U') | |
count++; | |
} | |
if(maxi<count){ | |
most_cringe = eid_msg; | |
// cout<<maxi <<" " << count <<" "<<most_cringe<<endl; | |
//count=0; | |
maxi=count; | |
} | |
} | |
cout<<"Most Cringy message Award goes to..... \n"<< most_cringe<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment