%100通过,用正则表达式 import java.util.Scanner; public class App { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()){ String str=sc.next(); String s1=sc.next(); String s2=sc.next(); boolean a=false,b=false; if(str.matches(".*"+s1+".*"+s2+".*")) a=true; if(str.matches(".*"+new StringBuilder(s2).reverse().toString()+".*" +new StringBuilder(s2).reverse().toString()+".*")) b=true; if(a&&b) System.out.println("both"); else if(a) System.out.println("forward"); else if(b) System.out.println("backward"); else System.out.println("invalid"); } } }
点赞 评论

相关推荐

求个付费实习岗位:这种就是吃满时代红利又没啥技术水平,只能靠压力学生彰显优越感的老登,别太在意了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务