Sort the letters of string in alphabetical order: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add C) |
Not a robot (talk | contribs) (Add C++) |
||
Line 228: | Line 228: | ||
<pre>Now is the time for all good men to come to the aid of their country. |
<pre>Now is the time for all good men to come to the aid of their country. |
||
.Naaccddeeeeeeffghhhiiiillmmmnnooooooooorrrstttttttuwy</pre> |
.Naaccddeeeeeeffghhhiiiillmmmnnooooooooorrrstttttttuwy</pre> |
||
=={{header|C++}}== |
|||
<lang cpp>#include <algorithm> |
|||
#include <iostream> |
|||
int main() { |
|||
std::string s = "Now is the time for all good men " |
|||
"to come to the aid of our country."; |
|||
std::cout << s << std::endl; |
|||
std::sort(s.begin(), s.end()); |
|||
std::cout << s << std::endl; |
|||
return 0; |
|||
}</lang> |
|||
{{out}} |
|||
<pre>Now is the time for all good men to come to the aid of our country. |
|||
.Naaccddeeeeeffghhiiillmmmnnoooooooooorrrsttttttuuwy</pre> |
|||
=={{header|C#|CSharp}}== |
=={{header|C#|CSharp}}== |