当前位置:网站首页>Niuke Xiaobai month race 7 F question

Niuke Xiaobai month race 7 F question

2022-07-04 19:37:00 Acacia moon tower

Title Description

Bob In the study DFS after , I invented a new search (luan) Cable (gao) Method , be called BFS(Bobby First Search).

This search is defined as : In a string , Find the first substring from front to back "Bob" Position of appearance .( Case insensitive )

 

Input description :

 Enter a string without spaces S( May contain upper and lower case letters , Numbers ).(1 ≤ |S| ≤ 100)

Output description :

 Output a number , Express "Bob" First occurrence ( Subscript from 0 Start ).

 If not , The output "-1".

Direct use JAVA Medium Indexof,,,,

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		a = a.toLowerCase();
		System.out.println(a.indexOf("bob"));
		in.close();
	}
}

 

原网站

版权声明
本文为[Acacia moon tower]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207041758484958.html