로그인후 결제를 간단하게 로그화해보는 알고리즘
public class grab1 { public static void main(String[] args) { String[] infos = {"id password"}; String[] actions = {"ADD 30", "LOGIN id pass", "LOGIN id paww", "LOGIN id password", "LOGIN id id", "LOGIN password password", "ADD 30", "ORDER", "ORDER", "ADD 40", "ADD 50"}; boolean[] answer = solution(infos, actions); System.out.print(" { "); for (int i = 0; i < answer.length; i++) { System.out.pri..
2021. 8. 22.
채점하기.. 본인이 채점한 점수가 최고값,최소값일 경우는 제외하고
학생들끼리 서로 채점하여, 본인의 점수가 유일한 최고점이거나, 최소점일 경우에는 본인이 채점한 본인의 점수를 제외하고 평균을 내어. 그 값으로 평점을 매기는 코드 public class pointingTest { public static void main(String[] args) { int[][] scores = {{100,90,98,88,65},{50,45,99,85,77},{47,88,95,80,67},{61,57,100,80,65},{24,90,94,75,65}}; String answer = solution(scores); System.out.println(answer); } private static String solution(int[][] scores) { int[][] a = scores..
2021. 8. 20.
체육복 서로 빌려줘 수업받을 수 있는 인원 확인하는 코드
import java.util.Arrays; public class sports { public static void main(String[] args) { int n = 10; int[] lost = {5,4,3,2,1}; int[] reserve = {3,1,2,5,4}; int answer = solution(n, lost, reserve); System.out.println("answer : "+answer); } private static int solution(int n, int[] lost, int[] reserve) { int answer = 0; Arrays.sort(lost); Arrays.sort(reserve); for (int i = 0; i < reserve.length; i++..
2021. 8. 20.
배열의 일부를 정렬하고 정렬한 수 중에 k 번째 수를 구하라.
public class kst { public static void main(String[] args) { int[] array = {1, 5, 2, 6, 3, 7, 4}; int[][] commands = {{2, 5, 3}, {4, 4, 1}, {1, 7, 3}}; int[] answer = solution(array, commands); System.out.print("{ "); for (int i = 0; i < answer.length; i++) { System.out.print(answer[i]); if(i!=answer.length-1) { System.out.print(","); } } System.out.println(" }"); } private static int[] solution(..
2021. 8. 20.
키패드에서 왼손엄지와 오른손엄지중 어느 것으로 누를지
public class keypad2 { public static void main(String[] args) { int[] numbers = {7, 0, 8, 2, 8, 3, 1, 5, 7, 6, 2}; String hand = "left"; String answer = solution(numbers, hand); System.out.println(answer); } private static String solution(int[] numbers, String hand) { int[] lp = {0,0}; int[] rp = {2,0}; int dl = 0; int dr = 0; int dl1 = 0; int dl2 = 0; int dr1 = 0; int dr2 = 0; String answer = "..
2021. 8. 19.