diff --git a/Basic_Of_Algorithm/src/interestingAlgorithm/Collatz_Graph.java b/Basic_Of_Algorithm/src/interestingAlgorithm/Collatz_Graph.java new file mode 100644 index 0000000..2291b9a --- /dev/null +++ b/Basic_Of_Algorithm/src/interestingAlgorithm/Collatz_Graph.java @@ -0,0 +1,31 @@ +package interestingAlgorithm; + +import java.util.Scanner; + +public class Collatz_Graph { + + public static void main(String[] args) { + + Scanner scan = new Scanner(System.in); + + int n = scan.nextInt(); + + + while(n!=1) { + + if(n%2==0) n /=2; + else n = (n*3) + 1; + + for(int i =0;iuser = new HashMap<>(); + + + for(String str : record) { + + String[]temp = str.split(" "); + + String action =temp[0]; + String id = temp[1]; + + if(action.equals("Leave"))continue; + + user.put(id, temp[2]); + + + } + + ArrayListanswerList = new ArrayList<>(); + + for(String str : record) { + + String[]temp = str.split(" "); + + String action = temp[0]; + String id = temp[1]; + + if(action.equals("Change"))continue; + + String nick = user.get(id); + + String ans = nick +"님이 " + (action.equals("Enter") ? "들어왔습니다." : "나갔습니다."); + + answerList.add(ans); + + + } + + + answer = new String[answerList.size()]; + + for(int i=0;i