Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String x = "Rilla";
- String y = "Pirin";
- boolean matching = false;
- int rowR = 0;
- int colC = 0;
- for(int row = 0; row < x.length(); row++){
- for(int col = 0; col < y.length(); col++){
- if(x.charAt(row) == y.charAt(col)){
- rowR = row;
- colC = col;
- matching = true; break;
- } }
- if(matching == true){break;}
- }
- for(int row = 0; row < x.length(); row++){
- if(row == rowR){
- for(int row2 = 0; row2 < y.length(); row2++){
- System.out.print(y.charAt(row2));
- }
- }
- else{
- for(int col2 = 0; col2 < colC; col2++)
- System.out.print(" ");
- for(int col2 = colC; col2 <= colC; col2++){
- System.out.print(x.charAt(row));}
- }
- System.out.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement