티스토리 뷰
Code
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int Word_Num(vector<string> &a, string &b);
int main()
{
ios::sync_with_stdio(NULL);
cin.tellg();
vector<string> str;
string s;
getline(cin, s);
str.push_back(s);
cout << Word_Num(str, s)+1 << "\n";
}
int Word_Num(vector<string> &a, string &b)
{
int count = 0;
for (int i = 0; i < a[0].length(); i++)
if (a[0][i] == ' ')
count++;
if (a[0][0] == ' ')
count--;
if (a[0][b.length() - 1] == ' ')
count--;
return count;
}
'프로그래밍 > BOJ' 카테고리의 다른 글
백준 알고리즘 [25083번] (C++) 새싹 (0) | 2022.07.18 |
---|---|
백준 알고리즘 [10828번] (C++) 스택 (0) | 2022.06.18 |
백준 알고리즘 [2292번] (C++) 벌집 (0) | 2019.08.06 |
백준 알고리즘 [2839번] (C++) 설탕 배달 (0) | 2019.08.05 |
백준 알고리즘 [1712번] (c++) 손익분기점 (0) | 2019.08.05 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 네트워크결합스토리지
- cin.getline()
- 데이터저장장치
- to_string
- 단어의 개수
- 토이사이퍼
- toy cipher
- 정수
- stringstream
- 웹 서버
- 25083
- 문자열입력
- 백준
- Web Server
- 알고리즘
- ??!
- 커널
- 자료구조
- web application server
- C++
- 파일입출력
- 쉘
- 웹 어플리케이션 서버
- boj
- 트리만들기
- 정수를 문자열로
- 운영체제
- getline()
- 1152
- 백준알고리즘
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함