• Home
  • About
    • JOOS photo

      JOOS

      Joos's blog

    • Learn More
    • Email
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

1213. [S/W 문제해결 기본] 3일차 - String

10 Dec 2018

Reading time ~1 minute

문제: https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14P0c6AAUCFAYi

package project;
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void Solved(){
		String sentence = sc.nextLine();
		String findSentence = sc.nextLine();
		int count = 0;
		for(int i=0; i<sentence.length(); i++){
			if(sentence.indexOf(findSentence,i)>=0){
				i = sentence.indexOf(findSentence,i);
				count++;
			}
		}
		System.out.println("count"+count);
	}

	public static void main(String args[]) {
		int TestCount = sc.nextInt();
		for(int i = 0; i < TestCount; i++){
			Solved();
		}
	}
}


algorithmjavasamsung Share Tweet +1