输入包括一行: 包括两个字符串,分别表示两条链,两个字符串长度相同且长度均小于等于50。
输出一个整数,即最少需要多少次让两条碱基链配对成功
ACGT TGCA
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s1 = sc.next(); String s2 = sc.next(); if (s1 == null || s2 == null || s1.length() != s2.length() || s1.isEmpty() || s2.isEmpty()) { return; } int count = 0; for (int i = 0; i < s1.length(); i ++) { if (s1.charAt(i) == 'A' && s2.charAt(i) == 'T') continue; if (s1.charAt(i) == 'T' && s2.charAt(i) == 'A') continue; if (s1.charAt(i) == 'C' && s2.charAt(i) == 'G') continue; if (s1.charAt(i) == 'G' && s2.charAt(i) == 'C') continue; count ++; } System.out.println(count); } }