인프런 커뮤니티 질문&답변
왜 틀린건지 모르겠습니다.
작성
·
206
0
import java.util.Scanner; public class Main { public static String solution(String s) { String[] tmp = s.split(" "); String answer = ""; for(int i=0; i<tmp.length-1; i++) { for(int j=i+1; j<tmp.length; j++) { if(tmp[i].length() > tmp[j].length()) { answer = tmp[i]; }else { answer = tmp[j]; } } } return answer; } public static void main(String[] args) { System.out.print("입력"); Scanner sc = new Scanner(System.in); String s = sc.nextLine(); System.out.print(solution(s)); } }
3. 문장속 단어 문제풀어서 결과는 제대로나오는데 채점사이트에서 틀렸다고합니다. 왜인지 알수있을까요?





