寒假每日一题打卡day9—— AcWing 1208. 翻硬币
作者:互联网
【题目描述】:
AcWing 1208. 翻硬币
【思路】
题目说一定有解,那只要将原状态往目标状态翻就一定可以达到要求。
import java.util.Scanner;
public class Main{
public static void change(char [] c1,int i){
if(c1[i]=='*') c1[i] = 'o';
else c1[i] = '*';
}
public static void main(String args[]){
Scanner reader = new Scanner(System.in);
String s1 =reader.next();
String s2 =reader.next();
char [] c1 = s1.toCharArray();
char [] c2 = s2.toCharArray();
int cnt = 0;
for(int i = 0; i < c1.length - 1; i++){
if(c1[i] != c2[i]){
cnt++;
change(c1,i);
change(c1,i+1);
}
}
System.out.println(cnt);
}
}
标签:cnt,1208,day9,int,char,reader,打卡,c1,String 来源: https://blog.csdn.net/weixin_44855907/article/details/112794029