코딩배우는 학생🧀

    [Programmers]  하샤드 수 [Java]

    [Programmers] 하샤드 수 [Java]

    문제 설명 양의 정수 x가 하샤드 수이려면 x의 자릿수의 합으로 x가 나누어져야 합니다. 예를 들어 18의 자릿수 합은 1+8=9이고, 18은 9로 나누어 떨어지므로 18은 하샤드 수입니다. 자연수 x를 입력받아 x가 하샤드 수인지 아닌지 검사하는 함수, solution을 완성해주세요. 제한 조건 x는 1 이상, 10000 이하인 정수입니다. 입출력 예 입출력 예 #1 10의 모든 자릿수의 합은 1입니다. 10은 1로 나누어 떨어지므로 10은 하샤드 수입니다. 입출력 예 #2 12의 모든 자릿수의 합은 3입니다. 12는 3으로 나누어 떨어지므로 12는 하샤드 수입니다. 입출력 예 #3 11의 모든 자릿수의 합은 2입니다. 11은 2로 나누어 떨어지지 않으므로 11는 하샤드 수가 아닙니다. 입출력 예 #4..

    [mySQL] Workbench에서 csv 파일 import 하기 [Mac]

    [mySQL] Workbench에서 csv 파일 import 하기 [Mac]

    mySQL Workbench를 이용해서 csv file을 import 하는 법 (본 방법은 window와 크게 다르지 않으나 글쓴이가 mac인 관계로 mac만 보여드리는 점 죄송합니다 (꾸벅)) 1. csv파일을 import하고자 하는 schema에 오른쪽 마우스로 클릭한다. 2. Table Data Import Wizard를 클릭 후 경로 설정 3. 만약에 미리 설정해둔 Table이 있다면 'Use existing table'선택, 아니라면 'Create new table'을 선택하고 Drop table if exists는 이미 있던 table을 삭제한다. 4. 각 Colume 변수의 Type에 따라 Field Type 설정, Encoding은 utf-8로 설정한다. ※ 만약 이런 화면이 나온다면 -c..

    [Programmers] 예산(서머코딩/윈터코딩/2018) [Java]

    [Programmers] 예산(서머코딩/윈터코딩/2018) [Java]

    문제 설명 S사에서는 각 부서에 필요한 물품을 지원해 주기 위해 부서별로 물품을 구매하는데 필요한 금액을 조사했습니다. 그러나, 전체 예산이 정해져 있기 때문에 모든 부서의 물품을 구매해 줄 수는 없습니다. 그래서 최대한 많은 부서의 물품을 구매해 줄 수 있도록 하려고 합니다. 물품을 구매해 줄 때는 각 부서가 신청한 금액만큼을 모두 지원해 줘야 합니다. 예를 들어 1,000원을 신청한 부서에는 정확히 1,000원을 지원해야 하며, 1,000원보다 적은 금액을 지원해 줄 수는 없습니다. 부서별로 신청한 금액이 들어있는 배열 d와 예산 budget이 매개변수로 주어질 때, 최대 몇 개의 부서에 물품을 지원할 수 있는지 return 하도록 solution 함수를 완성해주세요. 제한사항 d는 부서별로 신청한 ..

    [Programmers] 문자열 내 p와 y의 개수[Java]

    [Programmers] 문자열 내 p와 y의 개수[Java]

    문제 설명 대문자와 소문자가 섞여있는 문자열 s가 주어집니다. s에 'p'의 개수와 'y'의 개수를 비교해 같으면 True, 다르면 False를 return 하는 solution를 완성하세요. 'p', 'y' 모두 하나도 없는 경우는 항상 True를 리턴합니다. 단, 개수를 비교할 때 대문자와 소문자는 구별하지 않습니다. 예를 들어 s가 pPoooyY면 true를 return하고 Pyy라면 false를 return합니다. 제한사항 문자열 s의 길이 : 50 이하의 자연수 문자열 s는 알파벳으로만 이루어져 있습니다. 입출력 예 입출력 예 #1 'p'의 개수 2개, 'y'의 개수 2개로 같으므로 true를 return 합니다. 입출력 예 #2 'p'의 개수 1개, 'y'의 개수 2개로 다르므로 false를 ..

    015 - Conditional Statement Practice 1

    015 - Conditional Statement Practice 1

    The variable "num" holds an integer user input Write a conditional statement starting on line 9 that does the following: If num is positive, print "__ is positive" If num is negative, print "__ is negative" Examples: In: 5 5 is positive In: -2 -2 is negative In: 0 (no output for zero) import java.util.*; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in); ..

    011 - String Methods Practice 2

    011 - String Methods Practice 2

    Given three variables: String str int start int end Print out the following string: The substring of (str) from (start) to (end) is (substring from start to end, inclusive) Sample output: In: lolwut Start: 2 End: 4 The substring of lolwut from 2 to 4 inclusive is lwu PLEASE NOTE that we are counting the end index in our output! lolwut 012345 import java.util.Scanner; class Main { public static v..

    010 - String Methods Practice 1

    010 - String Methods Practice 1

    Given a String (already declared for you as str), do the following: Print out the following: "The first 3 letters of ___ is ___" For example, if the input is "banana", your output should be "The first 3 letters of banana is ban" import java.util.Scanner; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print("in:"); String str = inp.nextLine(..

    009 - String Methods - substring

    009 - String Methods - substring

    For you to do: (all output should be one per line) On line 6, write a print statement that prints out a substring of str starting at index 5 and going to the end On line 7, write a print statement that prints out a substring of str starting at index 7 and ending at index 10 On line 10, fill in the () in substring so that it prints "harambe" On line 11, fill in the () in substring so that it prin..

    008 - String Methods - indexOf

    008 - String Methods - indexOf

    For you to do: (the output should be one per line) Print out the position of the first occurrence of "c" Print out the position of the first occurrence of " " Print out the position of the first occurrence of the variable target1 Print out the position of the first occurrence of the variable target2 class Main { public static void main(String[] args) { String str = "abracadabra alakazam"; String..

    007 - String Methods - charAt

    007 - String Methods - charAt

    For you to do: ALL print statements in this exercise should be on one line, no newlines. Print out the character in the 5th index of the String str Print out the character in the 8th index of the String str Print out the character in the 1st index of the String str Print out the index in the i-th index of the String str (i is a variable already declared for you) class Main { public static void m..

    006 - String Methods - Length

    006 - String Methods - Length

    For you to do: Create a String named "name" and assign the value "Timmy" to it Print out the length of the string variable 'name' class Main { public static void main(String[] args) { String name="Timmy"; System.out.println(name.length()); } }

    005 - Creating Variables and Printing 5

    005 - Creating Variables and Printing 5

    Creating Variables and Printing 5 For you to do: Create a String variable called "name" and set it to "Chen" Create an integer variable called "age" and set it to 50 Create an integer variable called "iq" and set it to the value of age (do NOT use ' = 50') Print the value of name Print the value of age without skipping a new line Print the value of iq class Main { public static void main(String[..

    004 - Creating Variables and Printing 4

    004 - Creating Variables and Printing 4

    Creating Variables and Printing 4 Print out the following pattern: * ** *** ## # class Main { public static void main(String[] args) { System.out.println("*"); System.out.println("**"); System.out.println("***"); System.out.println("##"); System.out.println("#"); } }

    003 - Creating Variables and Printing 3

    003 - Creating Variables and Printing 3

    Creating Variables and Printing 3 For you to do: Create a boolean variable called "isTrue" and set it to false Create a double variable called "money" and set it to 99999.99 Print the variable "money" first Then print the variable "isTrue" without skipping to the next line. class Main { public static void main(String[] args) { boolean isTrue=false; double monet=99999.99; System.out.print(monet);..

    002 - Creating Variables and Printing 2

    002 - Creating Variables and Printing 2

    2019/11/26 Creating Variables and Printing 2 For you to do: Create an integer variable on line 4 and set it to the value 21. class Main { public static void main(String[] args) { int age=21; System.out.println(age); } }

    001 - Creating Variables and Printing 1

    001 - Creating Variables and Printing 1

    2019/11/26 Creating Variables and Printing Them For you to do: Create two String variables called firstName and lastName respectively. Assign the String "Bob" to firstName and "Jones" to lastName. Print firstName and lastName, one per line. Each should use a different print statement. import java.util.*; class Main { public static void main(String[] args) { String firstName ="Bob"; String lastNa..

    [Bakjoon/2562번] 최댓값 [Java]

    [Bakjoon/2562번] 최댓값 [Java]

    2019/11/26 문제 9개의 서로 다른 자연수가 주어질 때, 이들 중 최댓값을 찾고 그 최댓값이 몇 번째 수인지를 구하는 프로그램을 작성하시오. 예를 들어, 서로 다른 9개의 자연수 3, 29, 38, 12, 57, 74, 40, 85, 61 이 주어지면, 이들 중 최댓값은 85이고, 이 값은 8번째 수이다. 입력 첫 째 줄부터 아홉 번째 줄까지 한 줄에 하나의 자연수가 주어진다. 주어지는 자연수는 100 보다 작다. 출력 첫째 줄에 최댓값을 출력하고, 둘째 줄에 최댓값이 몇 번째 수인지를 출력한다. 예제 입/출력 풀이 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc =new Scann..

    [Bakjoon/10818번] 최소,최대 [Java]

    [Bakjoon/10818번] 최소,최대 [Java]

    2019/11/26 문제 N개의 정수가 주어진다. 이때, 최솟값과 최댓값을 구하는 프로그램을 작성하시오. 입력 첫째 줄에 정수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 N개의 정수를 공백으로 구분해서 주어진다. 모든 정수는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다. 출력 첫째 줄에 주어진 정수 N개의 최솟값과 최댓값을 공백으로 구분해 출력한다. 예제 입/출력 풀이 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int N =sc.nextInt(); int [] input= ne..

    [Programmers]제일 작은 수 제거하기[Java]

    [Programmers]제일 작은 수 제거하기[Java]

    2019/11/26 문제설명 정수를 저장한 배열, arr 에서 가장 작은 수를 제거한 배열을 리턴하는 함수, solution을 완성해주세요. 단, 리턴하려는 배열이 빈 배열인 경우엔 배열에 -1을 채워 리턴하세요. 예를들어 arr이 [4,3,2,1]인 경우는 [4,3,2]를 리턴 하고, [10]면 [-1]을 리턴 합니다. 제한조건 arr은 길이 1 이상인 배열입니다. 인덱스 i, j에 대해 i ≠ j이면 arr[i] ≠ arr[j] 입니다. 입출력 예 풀이 import java.util.*; class Solution { public int[] solution(int[] arr) { int[] answer = {}; ArrayList arr2 = new ArrayList(); if(arr.length

    [Programmers]직사각형 별찍기[Java]

    [Programmers]직사각형 별찍기[Java]

    2019/11/16 문제설명 이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다. 별(*) 문자를 이용해 가로의 길이가 n, 세로의 길이가 m인 직사각형 형태를 출력해보세요. 제한조건 n과 m은 각각 1000 이하인 자연수입니다. 예시 풀이 import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int j=0; while(j