티스토리 뷰


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;
}

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
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
글 보관함