AgentTadpole

Answers - Reversing Strings

Jan 16th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. PHP:
  2. echo strrev("Hello world!"); //outputs "!dlrow olleH"
  3.  
  4. Java:
  5. String string="Hello World";
  6. String reverse = new StringBuffer(string).reverse().toString();
  7. System.out.println(reverse); //outputs "dlroW olleH"
  8.  
  9. C++:
  10. string text = "Hello world";
  11. reverse = string ( text.rbegin(), text.rend() );
  12. cout << reverse; //outputs "dlrow olleH"
  13.  
  14. C: (must include <string.h>)
  15. char arr[100];
  16. arr = "Example text";
  17. strrev(arr);
  18. printf(arr); //outputs "txet elpmaxE"
Advertisement
Add Comment
Please, Sign In to add comment