본문 바로가기
알고리즘 & 자료구조/백준

백준 1152

by 신재권 2021. 7. 14.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main1152 {

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String s = bf.readLine().trim();
		int cnt = 0;
		for(int i=0; i<s.length(); i++){
			if(s.charAt(i) == ' ')
				cnt++;
		}
		
		if(s.isEmpty()){
			System.out.println("0");
		}else{
		System.out.println(cnt+1);
		}
	}

}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 5622  (0) 2021.07.16
백준 2908  (0) 2021.07.16
백준 1157  (0) 2021.07.14
백준 2675  (0) 2021.07.14
백준 10809  (0) 2021.07.13