ํฐ์คํ ๋ฆฌ ๋ทฐ
์ ๊ทผ๋ฐฉ๋ฒ
1. ํฌ๋ก์ํฐ์ ์ํ๋ฒณ ๋ฆฌ์คํธ๋ฅผ ๋ง๋ ๋ค.
2. ์ ๋ ฅ๋ ๋ฌธ์์ด๊ณผ ํฌ๋ก์ํฐ์ ์ํ๋ฒณ ๋ฆฌ์คํธ๋ฅผ ๋น๊ตํ๋ค.
3. ํฌ๋ก์ํฐ์ ์ํ๋ฒณ์ ๋ชจ๋ # ์ผ๋ก ๋ณ๊ฒฝ ํด์ค๋ค.
4. ์ํ๋ฒณ ํฌ๊ธฐ๋ฅผ ์ถ๋ ฅํ๋ค.
public class Main {
public static void main(String[] args) {
// ๋น๊ต ๋ฌธ์์ด
String[] alphabetList = {"c=","c-","dz=","d-","lj","nj","s=","z="};
String work = "ljes=njaknjnj";
for(int i = 0 ; i < alphabetList.length ;i++) {
if(work.contains(alphabetList[i])) {
work = work.replace(alphabetList[i], "#");
}
}
System.out.println("์ํ๋ฒณ ์ซ์๋ : "+work.length());
}
}
'โ Algorithm ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ ๋ฐฑ์ค ] 1065 ํ์ (0) | 2021.04.29 |
---|---|
[ ๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ 1924๋ฒ] 2007๋ (0) | 2019.11.01 |
[ ๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ 1152๋ฒ ] ๋จ์ด์ ๊ฐ์ (0) | 2019.10.29 |
๋๊ธ
๋ฐ์ํ