Algorithm

    백준 2884 (알람 시계)

    1234567891011121314151617181920212223242526import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); // hour를 입력 int b = scan.nextInt(); // minute을 입력 scan.close(); if(b

    백준 1152 (단어의 개수)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); scan.close(); StringTokenizer st = new StringTokenizer(input," "); // input(문자열)값을 " "(공백)기준으로 각각 나누어 토큰화 System.out.println(st.countTokens()); // 나누어진 토큰 갯수를 출력 } } C..

    백준 2754 (학점 계산)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 import java.util.Scanner; public class baekjoon_2754 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); float a = 0f; if(input.charAt(0)=='A') { a += 4.0; if(input.charAt(1)=='+') { ..

    백준 2744 (대소문자 바꾸기)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 import java.util.Scanner; public class baekjoon_2744 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); // 문자열(input)을 char형식의 배열 a에 저장 char[] a = input.toCharArray(); for(int i=0; i='A' && a[i]='a' && a[i]

    백준 2738 (행렬 덧셈)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 import java.util.Scanner; public class baekjoon_2738 { // 행렬 덧셈 public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); // N * M 크기의 행렬 생성 int sum[][] = new int[N][M]; // N * M의 행렬의 각각 원소 값을 두 번씩 입력 받아 더한다. for(int i=0; i

    백준 1271번 (엄청난 부자2)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 // 입력 범위가 10의 1000제곱으로 거의 무한에 가까운 숫자를 사용한다. // 숫자의 범위가 무한인 BigInteger를 이용한다.(문자열 형태로 이루어져 있다.) import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); BigInteger a = scan.nextBigInteger(); BigInteger b = scan.nextBigInteger(); // 문자열 형태로 이루어져..

    코드업 기초 1099번 문제 해답

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 // 코드업 기초 1099번 문제 #include int main(void) { int i, j; int a[10][10] = { 0 }; // 10*10 2차원 배열안에 모든 값 0으로 초기화 for (i = 0; i

    코드업 기초 1098번 문제 해답

    // 코드업 기초 1098번 문제 #include int main(void) { int w, h, n, d, x, y, l, i, j; int a[100][100] = { 0 }; // 입력값의 최대 범위인 2차원 배열 선언 및 초기화 scanf_s("%d %d", &h, &w); // 격자판의 크기 입력 (세로(h) x 가로(w)) scanf_s("%d", &n); // 막대의 개수 입력 for (i = 1; i