deyanmalinov

02. Common Elements

Feb 14th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package DPM;
  2. import java.util.*;
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         String[] fmas = scan.nextLine().split(" ");
  7.         String[] smas = scan.nextLine().split(" ");
  8.         for (int i = 0; i < smas.length; i++) {
  9.             for (int j = 0; j < fmas.length; j++) {
  10.                 if (smas[i].equals(fmas[j])){
  11.                     System.out.print(smas[i]+" ");
  12.                     break;
  13.                 }
  14.  
  15.             }
  16.  
  17.         }
  18.     }
  19. }
Add Comment
Please, Sign In to add comment