码迷,mamicode.com
首页 > 编程语言 > 详细

2271=Eddy的难题(JAVA)

时间:2019-10-24 23:47:17      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:util   new   print   scanner   div   imp   stat   aaa   错误   

 1 import java.util.Scanner;
 2 public class Main {
 3     public static void main(String[] args) {
 4         Scanner input = new Scanner(System.in);
 5         while(input.hasNext()) {
 6             String a = input.nextLine();
 7             String b = input.nextLine();
 8             /*
 9              * 可能有人对这里有疑问,为什么要判断长度,a的长度小 那肯定不包含,那是因为本题可以移位,在这里我假设两
10              * 个字符串,a:AA,b:AAA,很明显不是亲和串,但是我 们的算法问题,导致在判断是我们会将AA扩展成AAAA,这 样判断会导致结果错误。
11              */
12             if(a.length()<b.length()) {
13                 System.out.println("no");
14             }
15             else {
16                 a=a+a;
17                 if(a.indexOf(b)!=-1)System.out.println("yes");
18                 else System.out.println("no");
19             }
20         }
21     }
22 }

 

2271=Eddy的难题(JAVA)

标签:util   new   print   scanner   div   imp   stat   aaa   错误   

原文地址:https://www.cnblogs.com/Angfe/p/11735513.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!