Advertisement
Guest User

Yay for restrictions

a guest
Oct 21st, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. moveXdown takes a char and a String as input and returns a String:
  2. The output string should be the same as the input string except that the first occurrence of the input character should be swapped with one other character of the string. The character the input character is swapped with should be after the next occurrence of the special end-of-line character '\n', the same number of characters after the end-of-line character as the first occurrence is after either its previous end-of-line character or the start of the string, and before the next end-of-line character. If no such character exists in the string, the output should be the same as the input string.
  3.  
  4. > HW2.moveXdown('X', "abcXd\nefghi\njklm")
  5. "abchd
  6. efgXi
  7. jklm"
  8. > HW2.moveXdown('X', "abchd\nefgXi\njklm")
  9. "abchd
  10. efgmi
  11. jklX"
  12. > HW2.moveXdown('X', "abcXd\nefg\njklm")
  13. "abcXd
  14. efg
  15. jklm"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement