Computer Science
[백준] 단어의 개수 1152번
jhkang-dev
2018. 10. 3. 20:28
단어의 개수 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) 코드가 이해가 되지 않는다.
왜 이렇게 해서 정답이 되는지 알아봐야 겠다.