fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. char
  6. ctl(char c) {
  7. return c > '@' && c < '[' ? c + ' ' : c;
  8. }
  9.  
  10. char
  11. ctu(char c) {
  12. return c > '`' && c < '{' ? c - ' ' : c;
  13. }
  14.  
  15. int
  16. main(int, char **) {
  17. ::std::string test { "Some string only WITH ASCII symBols ;)" };
  18. ::std::cout << test << '\n';
  19. ::std::transform(test.begin(), test.end(), test.begin(), ctl);
  20. ::std::cout << test << '\n';
  21. ::std::transform(test.begin(), test.end(), test.begin(), ctu);
  22. ::std::cout << test << '\n';
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5476KB
stdin
Standard input is empty
stdout
Some string only WITH ASCII symBols ;)
some string only with ascii symbols ;)
SOME STRING ONLY WITH ASCII SYMBOLS ;)