Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3. String x = "Rilla";
  4. String y = "Pirin";
  5. boolean matching = false;
  6. int rowR = 0;
  7. int colC = 0;
  8.  
  9. for(int row = 0; row < x.length(); row++){
  10. for(int col = 0; col < y.length(); col++){
  11. if(x.charAt(row) == y.charAt(col)){
  12. rowR = row;
  13. colC = col;
  14. matching = true; break;
  15. } }
  16. if(matching == true){break;}
  17. }
  18. for(int row = 0; row < x.length(); row++){
  19. if(row == rowR){
  20. for(int row2 = 0; row2 < y.length(); row2++){
  21. System.out.print(y.charAt(row2));
  22. }
  23. }
  24. else{
  25. for(int col2 = 0; col2 < colC; col2++)
  26. System.out.print(" ");
  27. for(int col2 = colC; col2 <= colC; col2++){
  28. System.out.print(x.charAt(row));}
  29. }
  30.  
  31.  
  32.  
  33. System.out.println();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement