连续的四个碱基的重复
不能判断是否有多个碱基的重复
public class TestConsecutiveBases{ public static void main (String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter the number of values: "); String DNASeq = input.nextLine(); if (isConsecutiveFour(DNASeq)) System.out.println("The series has consecutive four bases"); else System.out.println("The series has no consecutive four bases"); } public static boolean isConsecutiveFour(String T) { char[] DT = T.toCharArray(); for (int i = 0; i < DT.length - 3; i++) { boolean isEqual = true; for (int j = i; j < i + 3; j++) { if (DT[j] != (DT[j + 1])) { isEqual = false; break; } } if (isEqual) return true; } return false; } }
时间: 2024-10-08 06:28:13