Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class SequenceOfEqualStrings02 {
  5.  
  6. public static void main(String[] args) {
  7. Scanner in = new Scanner(System.in);
  8. String[] input = in.nextLine().split(" ");
  9. System.out.print(input[0]);
  10. for (int i = 1; i < input.length; i++) {
  11. if(input[i].equals(input[i-1])){
  12. System.out.print(" " + input[i]);
  13. }
  14. else{
  15. System.out.println();
  16. System.out.print(input[i]);
  17. }
  18. }
  19.  
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement