SW Expert Academy
SW ํ๋ก๊ทธ๋๋ฐ ์ญ๋ ๊ฐํ์ ๋์์ด ๋๋ ๋ค์ํ ํ์ต ์ปจํ ์ธ ๋ฅผ ํ์ธํ์ธ์!
swexpertacademy.com
์ฐพ์ ๋ฌธ์์ด์์ ๊ฒ์์ด๊ฐ ์์ผ๋ฉด ์๋ง ์ธ๋ฉด๋๋๊น, replaceAll์ด์ฉํ์ฌ ๊ฒ์์ด๋ฅผ *๋ก ๋์ฒดํ๊ณ
*๋ฅผ ์นด์ดํ ํจ.
import java.util.Scanner;
class Solution{
public static void main(String args[]) throws Exception {
Scanner kb = new Scanner(System.in);
int[] answer=new int[10];
int cnt=0;
for(int test_case=0; test_case<10; test_case++){
int n=kb.nextInt();
String s=kb.next();
String f=kb.next();
f=f.replaceAll(s,"*");
for(char x:f.toCharArray()){
if(x=='*')
cnt++;
}
answer[test_case]=cnt;
cnt=0;
}
for(int i=0; i<answer.length; i++) System.out.println("#"+(i+1)+" "+answer[i]);
}
}
'๐ ์ฝ๋ฉํ ์คํธ > ๋ฐฑ์ค & ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 0 : ์ปจํธ๋กค ์ ํธ (1) | 2022.11.05 |
---|---|
[SWEA][JAVA]D3 : ๊ณ์ฐ๊ธฐ (0) | 2022.11.04 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : ์ซ์ ์ง๊ถ (0) | 2022.11.04 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 0 : ์ง์ฌ๊ฐํ ๋์ด ๊ตฌํ๊ธฐ (0) | 2022.11.04 |
[SWEA][JAVA]D3 : ์ก์ด (0) | 2022.11.03 |