/******************************************************************************/ /* */ /* FILE: september.cpp */ /* */ /* Sorting a strange looking string sends to a message to the world */ /* ================================================================ */ /* */ /* Compiled and tested with Visual C++ 6.0 */ /* */ /* V1.00 30-SEP-2003 P. Tellenbach https://www.heimetli.ch */ /* */ /******************************************************************************/ #include <iostream> #include <string> #include <algorithm> #include <functional> using namespace std ; bool comp( char a, char b ) { if( a == b ) return false ; return (a == ' ') || ((b != ' ') && (a > b)) ; } int main() { string str = "elHloow lrd!" ; sort( str.begin() + 8, str.end() - 1, greater<char>() ) ; sort( str.begin() + 5, str.begin() + 8, comp ) ; sort( str.begin(), str.begin() + 5 ) ; cout << str << endl ; return 0 ; }
Update 30. September 2023
This program compiles and runs without any changes.