[백준] P1543

동민·2021년 3월 11일
0
import java.util.Scanner;

public class P1543 {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int answer = 0, index = 0;
		String doc = sc.nextLine(), word = sc.nextLine();

		while(index <= doc.length() - word.length() && index + word.length() <= doc.length()) {
			if(doc.substring(index, index + word.length()).equals(word)) {
				answer ++;
				index += word.length();
				continue;
			}
			index ++;
		}
		System.out.println(answer);
		sc.close();
	}
}
profile
BE Developer

0개의 댓글