Advertisement
DNNdrago

2. Sequences of Equal Strings

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