반응형

알고리즘/코딩도장 8

가~위 바위~ 보!

코딩도장 - 가~위 바위~ 보! package may31; import java.util.Arrays; import java.util.Scanner; public class Test01 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("몇판 하시겠습니까?");//게임 횟수 int input = sc.nextInt(); int[] result = new int[3];// 승무패 횟수 카운트 char[] result2 = new char[input];//승 무 패 결과값 저장 for(int i = 0; i < input; i++) { int input2; do { System.ou..

구글 입사 문제 중에서

코딩도장 - 구글 입사 문제 중에서 public class Main { public static void main(String[] args) { int[] N = new int[10000]; int count = 0; for (int i = 0; i < N.length; i++) { N[i] = i; // 값 대입용 if (N[i] % 10 == 8) { //System.out.println(i + " 1의 자리"); // 1의 자리 카운트 count++; } N[i] = N[i] / 10; if (N[i] % 10 == 8) { //System.out.println(i + " 10의 자리"); // 10의 자리 카운트 count++; } N[i] = N[i] / 10; if (N[i] % 10 == 8..

CamelCase를 Pothole_case로 바꾸기!

코딩 도장 CamelCase를 Pothole_case로 바꾸기 import java.util.Scanner; public class Camel2Pothole { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String word = sc.nextLine();//입력 for (int i = 0; i < word.length(); i++) { if(Character.isUpperCase(word.charAt(i))||Character.isDigit(word.charAt(i))){//대문자, 숫자 일시 System.out.print("_"+Character.toLowerCase(word.charAt(i)));// _삽..

타노스의 핑거 스냅

코딩도장 - 타노스의 핑거 스냅 import java.util.Arrays; public class Tanos { public static void main(String[] args) { int[] people = {2, 3, 1, 6, 5, 7, 8}; int ran = people.length/2; if(people.length%2==1) {//원소가 홀수라면 ran = (int) (Math.random()*2 + 1);// 1,2 절반 확률 if(ran%2==1) { ran = (people.length/2)+1;// 1일때 배열초기화 값 저장 System.out.println("1일때"); } else { ran = (people.length/2);// 2일때 배열초기화 값 저장 System.ou..

반응형