Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * @author modeh
- *
- */
- public class XX {
- public static void main(String a[]) {
- Scanner st = new Scanner(System.in);
- String user = st.next();
- String pass = st.next();
- int c = 0;
- boolean z=true;
- int min = Math.min(user.length(), pass.length());
- int max=Math.max(user.length(), pass.length());
- if (pass.length() < 8) {
- System.out.println("no");
- } else if (user.equals(pass) || pass.equals(user)) {
- System.out.println("yes");
- } else {
- for (int i = 0; i < min; i++) {
- if(!z)break;
- if (user.charAt(i) != pass.charAt(i)) {
- c++;
- if (c > 1) {
- System.out.println("no");
- z=false;
- break;
- }
- //algorithms
- //algorthms
- if(max!=min) {
- for (int j = i+1; j <min; j++) {
- // System.out.println(user.charAt(j)+" "+pass.charAt(j - 1));
- if (user.charAt(j) != pass.charAt(j - 1)) {
- c++;
- if (c > 1) {
- System.out.println("no");
- z=false;
- break;
- }
- }
- else if(j<max-1){
- z=false;
- }
- }
- }
- }
- }
- //System.out.println(c);
- if (c <= 1) {
- System.out.println("yes");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement