I have a project and I want to ask for some things. How can I make a string with descending order using cin<<word;
? I tried this from a website that I found but it doesn't work with cin. Here is the code:
void descOrder(string s)
{
sort(s.begin(), s.end(), greater<char>());
}
int main()
{
string s = "geeksforgeeks";
descOrder(s); // function call
return 0;
}
To be more clear I want to do this
- Input:
geek for geeks
- Output
ssrokkggfeeee
Also, how can I replace letters from a string using the alphabet, for instance, the Hello I want to be like this H to be I, e to be f, l to be m, o to be p, and if a word contains the letter z I want to replace with the letter a.
The final question I want to print from a string first the according and after the vowels