Advertisement
coasterka

#4SequencesOfEqualStrings

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