package compl; import java.util.*; public class sr { public sr() { } static int[] sravn(String seq1, String seq2) { int n1 = seq1.length(); int n2 = seq2.length(); int n = Math.max(n1, n2); seq1 = add(seq1, n); seq2 = add(seq2, n); int[] S = new int[4]; for (int i = 0; i < 4; i++) { S[i] = 0; } for (int i = 0; i < n; i++) { if (seq1.charAt(i) == seq2.charAt(i)) { if (seq1.charAt(i) == 'H') { S[0]++; } else { S[1]++; } } else { if (seq1.charAt(i) == 'H') { S[3]++; } else { S[2]++; } } } return S; } static String add(String seq, int n) { for (int i = seq.length(); i < n; i++) { seq +="0"; } return seq; } public static void main(String[] args) { long t0 = System.currentTimeMillis(); String seq1 = "---HHH"; String seq2 = "-HHH"; int[] S; S = sravn(seq1, seq2); int n1 = seq1.length(); int n2 = seq2.length(); int n = Math.max(n1, n2); seq1 = add(seq1, n); seq2 = add(seq2, n); System.out.println("seq1 = " + seq1); System.out.println("seq2 = " + seq2); System.out.println("TP = " + S[0]); System.out.println("TN = " + S[1]); System.out.println("FP = " + S[2]); System.out.println("FN = " + S[3]); long t1 = System.currentTimeMillis(); System.out.println("time = " + (t1 - t0)); } }