Short Cake
8PM - Animal Crossing Wild World

사생활 보호 설정

https://gamjia.tistory.com

Mini Rooms

  • 내 미니룸
  • 미니미설정
  • 미니룸설정
  • 답글수 [0]

What Friends Say

한마디로 표현해봐~

1촌평 관리

1152번 단어의 개수

GamJia 2023. 3. 27. 09:14

단계별로 풀어보기 - 문자열 - 6단계

https://www.acmicpc.net/problem/1152

#include <iostream>
#include <string>
using namespace std;

int main() {
	string S;
	getline(cin, S);
	int count=1;

	for(int i=0; i<S.length();i++)
    {
		if(S[i]==' ')
        {
            count++;
        }			
	}

	if(S[0]==' ') 
    {
        count--;
    }
		
	if(S[S.length()-1]==' ')
    {
        count--;
    }
	cout<<count;
    
    return 0;
}
​

'BaekJoon' 카테고리의 다른 글

5622번 다이얼  (0) 2023.03.27
2908번 상수  (0) 2023.03.27
1157번 단어 공부  (0) 2023.03.27
2675번 문자열 반복  (0) 2023.03.27
10809번 알파벳 찾기  (0) 2023.03.24