사용자가 입력한 단어를 알파벳순으로 정렬하는 문제222입니다 이를 해결하는 다음 프로그램에 대해 빈칸을 채우세요
단어를 입력하세요: carrot 단어를 입력하세요: banana 단어를 입력하세요: apple 단어를 입력하세요: dog 단어를 입력하세요: egg apple banana carrot dog egg
단어를 입력하세요: 귤 단어를 입력하세요: 배 단어를 입력하세요: 사과 단어를 입력하세요: 포도 단어를 입력하세요: 바나나 귤 바나나 배 사과 포도
단어를 입력하세요: 기차 단어를 입력하세요: 버스 단어를 입력하세요: 택시 단어를 입력하세요: 자동차 단어를 입력하세요: 비행기 기차 버스 비행기 자동차 택시
java.util.;
public class WordSort
{
public static void main( String[] args ) {
scan = ( );
words = { "", "", "" };
( index = 0; index words.; index ) {
( "단어를 입력하세요: " );
wordsindex = scan.();
}
( last = words. - 1; 0 last; last ) {
( index = 0; index last; index ) {
( wordsindex.( wordsindex+1 ) 0 ) {
temp = wordsindex;
wordsindex = wordsindex+1;
wordsindex+1 = temp;
}
}
}
( word words )
( word + " " );
scan.close();
}
}