티스토리 뷰

단어의 개수 1152번(문제 : https://www.acmicpc.net/problem/1152)



소스코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
    int cnt = 0;
    string s;
 
    while (cin >> s) {
        cnt += 1;
    }
    
    cout << cnt << '\n';
    return 0;
}
cs


이 코드에서 while(cin >> s) 코드가 이해가 되지 않는다.


왜 이렇게 해서 정답이 되는지 알아봐야 겠다.






'Daily Algorithm Solving' 카테고리의 다른 글

[BOJ] 2309번 일곱 난장이  (0) 2019.02.10
[백준] 문자열 분석 10820번  (0) 2018.10.03
[백준] 저항 1076번  (0) 2018.09.29
[백준] 알파벳 찾기 10809번  (0) 2018.09.27
[백준] 오르막수 11057번  (0) 2018.09.16
댓글