Question: #include #include #include #include #include using namespace std; int main() { string str; getline(cin, str); unordered_map mp; mp[life] = zindagi, mp[complex] = mushkil, mp[mistakes] =
#include
#include
#include
#include
#include
using namespace std;
int main()
{
string str;
getline(cin, str);
unordered_map
mp["life"] = "zindagi", mp["complex"] = "mushkil", mp["mistakes"] = "ghaltiyan", mp["important"] = "zaroori",mp["stronger"] = "taqatwar";
mp["people"] = "log", mp["forever"] = "humeshah", mp["wait"] = "intazar", mp["hurt"] = "dukh mei", mp["help"] = "madad";
mp["alone"] = "akela", mp["world"] = "duniyan", mp["someone"] = "koi", mp["good"] = "achi", mp["thing"] = "cheez";
mp["human"] = "insan", mp["many"] = "bohat", mp["tired"] = "thakay", mp["they"] = "woh", mp["enough"] = "kafi", mp["house"] = "ghar", mp["some"] = "kuch"
, mp["stomach"] = "pait", mp["empty"] = "khali", mp["thankful"] = "shukar guzar";
string st = "";
for (int i = 0; i < str.size(); i++)
{
if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) st+=(str[i]);
else if (str[i] == ' ' || str[i] == '.' || str[i] == ',' || str[i] == '!' || str[i] == '?')
{
string cpy = st;
if (st[0] >= 'A' && st[0] <= 'Z')
st[0] += 32;
//cout< if (mp.find(st) != mp.end()) { string res = mp[st]; if (cpy[0] >= 'A' && cpy[0] <= 'Z') res[0] -= 32; cout << res; } else cout << cpy; cout << str[i]; st.clear(); } } return 0; } Solve it in C++ I will give thumb up for u
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
