自己写的Double.toString().equals()
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String str = in.nextLine();
            int n = Integer.valueOf(in.nextLine());
            int start = 0;
            double GC_Ratio = 0;
            for (int i = 0; i < str.length() - n; i++) {
                for (int j = i; j < str.length() - n; j++) {
                    String sub = str.substring(j, j + n);
                    int nums_GC = 0;
                    for (char ch : sub.toCharArray()) {
                        if (ch == 'G' || ch == 'C') {
                            nums_GC++;
                        }
                    }
                    double temp_GC_Ratio = (double)nums_GC / n;
                    if (temp_GC_Ratio > GC_Ratio) {
                        GC_Ratio = temp_GC_Ratio;
                        start = j;
                    } else if (Double.toString(GC_Ratio).equals(Double.toString(temp_GC_Ratio)) &&  start > j) {
                        start = j;
                    }
                }
            }
            System.out.println(str.substring(start, start + n));
        }
    }
}
 投递峰飞航空等公司10个岗位
投递峰飞航空等公司10个岗位 查看30道真题和解析
查看30道真题和解析

