Java代码
今天的题很简单,基本上看一遍代码就懂了
//递推
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
static int N = 110;
static char[] a = new char[N];
static char[] b = new char[N];
public static void main(String[] args)throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str1 = br.readLine();
String str2 = br.readLine();
a = str1.toCharArray();
b = str2.toCharArray();
int res = 0;
for(int i = 0; i < a.length - 1; i ++) //一共n - 1种操作
{
if(a[i] != b[i]) //如果不相同就进行翻转
{
res++;
turn(i); turn(i + 1);
}
}
System.out.print(res);
}
private static void turn(int i )
{
if(a[i] == '*') a[i] = 'o';
else if(a[i] == 'o') a[i] = '*';
}
}