고려해야할 조건은 크게 2가지다.
만약 두 수의 길이가 같다면
-> 각자리가 둘 다 '8'일 때만 카운트 ( 88 / 88 )
-> 각자리가 '8'이 아니고 같은 경우 뒤에 '8' 나올 수 있기 때문에 continue ( 88 / 98 )
-> 각자리가 '8'도 아니고 다른 수인 경우 '8'이 없어도 되는 수가 있기 때문에 break; ( 790 / 981 )
만약 두 수의 길이가 다르면 '8'이 없어도 되기 때문에 return ( 80000 / 8918283 )
package problem_solving.greedy;
import java.util.Scanner;
public class BaekJoon_1105 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder L = new StringBuilder(sc.next());
StringBuilder R = new StringBuilder(sc.next());
int answer =0;
if(L.length() ==R.length ()){
for(int i =0 ; i < L.length();i++){
if(L.charAt(i) =='8' && R.charAt(i) =='8' ){
answer++;
} else if (L.charAt(i) ==R.charAt(i) ) {
continue;
} else {
break;
}
}
System.out.println(answer) ;
}
}
}