zoukankan      html  css  js  c++  java
  • 判断串是否为回环变位串

    题目:如果字符串s中的字符循环移动任意位置之后能够得到另一个字符串t,那么s就被称为t的回环变位。例如,ACTGACG就是TGACGAC的一个回环变位,反之亦然。判定这个条件在基因组序列的研究中是很重要的。编写一个程序检查两个给定的字符串s和t是否为回环变位。

    上代码:

    import java.io.BufferedInputStream;
    import java.util.Scanner;
    
    public class test {
        public static void main(String[] args) {
            Scanner cin = new Scanner(new BufferedInputStream(System.in));
            String s = cin.next();
            String t = cin.next();
            cin.close(); // indexOf返回指定子字符串在此字符串中第一次出现处的索引,如果找不到子串就返回-1
            if ((s.length() == t.length()) && (s.concat(s).indexOf(t) >= 0)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }


    ========================================Talk is cheap, show me the code=======================================

    CSDN博客地址:https://blog.csdn.net/qq_34115899
  • 相关阅读:
    ASP.NET MVC 动态加载图像
    ASP.NET:以域用户身份访问网络资源
    ASP.NET MVC 动态加载 *.ascx
    4月
    3月
    2月
    每天充点小能量
    每天进步一点点
    FreeMarker标签与使用
    eclipse启动tomcat, http://localhost:8080无法访问
  • 原文地址:https://www.cnblogs.com/lcy0515/p/9179773.html
Copyright © 2011-2022 走看看