몇 줄 입력받는다는 게 안 주어지면
while (cin >> s) { }
이런 방식으로 풀 수 있다는 걸 알고있다.
그런데 이 문제는 줄에 빈 칸이 주어져서 문제였다ㅋㅋ
검색해보니 getline() 함수를 쓰는 것 같다. 전에 본 적 있는 것 같은데?? 기억이 가물함
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int main()
{
char s[101];
int ans = 0;
while (cin.getline(s, 100))
{
ans++;
}
cout << ans << endl;
return 0;
}
'백준' 카테고리의 다른 글
5568 카드 놓기 (0) | 2020.09.09 |
---|---|
2839 설탕 배달 (0) | 2020.09.08 |
2608 로마 숫자 (0) | 2020.09.06 |
15989 1, 2, 3더하기 4 (0) | 2020.09.06 |
1411 비슷한 단어 (0) | 2020.09.05 |