Skip to content

Commit 5f8b0d3

Browse files
committed
Solve: 28번문제 해결
1 parent 9c0715c commit 5f8b0d3

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 문제28 : 2-gram
2+
3+
**2-gram**이란 문자열에서 2개의 연속된 요소를 출력하는 방법입니다.
4+
5+
예를 들어 'Javascript'를 2-gram으로 반복해 본다면 다음과 같은 결과가 나옵니다.
6+
7+
```jsx
8+
**입력**
9+
Javascript
10+
11+
**출력**
12+
J a
13+
a v
14+
v a
15+
a s
16+
s c
17+
c r
18+
r i
19+
i p
20+
p t
21+
```
22+
23+
입력으로 문자열이 주어지면 **2-gram**으로 출력하는 프로그램을 작성해 주세요.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// # 문제28 : 2-gram
2+
3+
// **2-gram**이란 문자열에서 2개의 연속된 요소를 출력하는 방법입니다.
4+
5+
// 예를 들어 'Javascript'를 2-gram으로 반복해 본다면 다음과 같은 결과가 나옵니다.
6+
7+
8+
// **입력**
9+
// Javascript
10+
11+
// **출력**
12+
// J a
13+
// a v
14+
// v a
15+
// a s
16+
// s c
17+
// c r
18+
// r i
19+
// i p
20+
// p t
21+
22+
23+
// 입력으로 문자열이 주어지면 **2-gram**으로 출력하는 프로그램을 작성해 주세요.
24+
const word = "Javascript";
25+
26+
function twoGram(word) {
27+
for (let i = 0; i < word.length - 1; i++) {
28+
console.log(word[i], word[i + 1]);
29+
}
30+
}
31+
32+
twoGram(word);

0 commit comments

Comments
 (0)