사생활 보호 설정
https://gamjia.tistory.com
Updated News
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; }