답변 하려고 했더니 이미 달렸음..

밑에 것들도 줄줄이.. ㅎ

 

 

A. 질문

 

http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1040201&docId=262328845

 

 

B.  내 답변

 

1. CLASS

 

import java.util.Scanner;

 

public class test12_005 {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
  
    int no = sc.nextInt();
    int count = 1;
  
    String mun[] = new String[no];
    String str = "";


    for(int i = 0; i < no; i++){
      mun[i] = sc.next();

      int bno = 0;


      if(i > 0){
        for(int j = 0; j < i; j++){
          if(mun[i].equals(mun[j])){
            System.out.println("중복되는 단어가 있습니다.  다시 입력하세요!");
            i--;

            bno = 1;
          }
        }
        if(!mun[i].substring(0, 1).equals(mun[i - 1].substring(mun[i - 1].length() - 1))){

          if(bno == 0){
            str += mun[i] + " ";
            count++;

          }
        }
      }else{
        str += mun[i] + " ";
      }
    } 
    System.out.println(count + " " + str);
  }
}


 

2. RUN

 

5
abc
cde
efg
efg
중복되는 단어가 있습니다.  다시 입력하세요!
ase
rdf
3 abc cde efg

 

 

'interest > 지식인 관련..' 카테고리의 다른 글

지식인 활동으로 1000개, 공익갬페인으로 145개의 콩을 기부했다.  (0) 2016.08.30
카운트 다운 8  (0) 2016.08.19
별일  (0) 2016.08.19