蓝桥杯(3.15 刷真题)
·
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s1 = sc.nextLine();
String s2 = sc.nextLine();
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
int t = c1.length - 1;
int sum = 0;
for(int i=0;i<t;i++) {
if(c1[i]!=c2[i]) {
if(c1[i] == '*') {
c1[i] = 'o';
if(c1[i+1] == '*') {
c1[i+1] = 'o';
}else {
c1[i+1] = '*';
}
sum++;
}else {
c1[i] = '*';
if(c1[i+1] == '*') {
c1[i+1] = 'o';
}else {
c1[i+1] = '*';
}
sum++;
}
}
}
System.out.println(sum);
}
}
更多推荐
已为社区贡献3条内容
所有评论(0)