공백을 포함한 문장을 입력 받아서 홀수 번째 단어를 차례로 출력하는 프로그램을 작성하시오.
문장의 길이는 100자 이하이다.
I like you better than him.
I
you
than
package com.jungol.algorithm181;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String[] ar = sc.nextLine().split(" ");
for(int i = 0; i < ar.length; i++) {
if(i % 2 == 0) {
System.out.println(ar[i]);
}
}
sc.close();
}
}