본문 바로가기

반응형

Projects

(71)
경찰 조서 작성 게임? #include int main() { // 프로젝트 // 경찰관이 범죄자의 정보를 입수 (조서 작성) // 이름? 나이, 몸무게, 키 범죄명 char name[256]; printf("이름이 뭐에요?\n"); scanf_s("%s", name, sizeof(name)); int age; printf("몇 살이에요?\n"); scanf_s("%d", &age); float weight; printf("몸무게는 몇 kg 이에요?\n"); scanf_s("%f", &weight); double height; printf("키는 몇 cm에요?\n"); scanf_s("%lf", &height); char what[256]; printf("무슨 범죄를 저질렀어요?\n"); scanf_s("%s", what, s..
주어진 숫자의 각 자리수 더하기 자바 import java.util.Scanner; public class Add { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String num = sc.nextLine(); int sum=0; String[] nums = num.split(""); int[] ele_sum = new int[nums.length]; for (int i=0;i
Java Banking application 자바 뱅킹 어플리케이션 프로젝트 import java.util.Scanner; public class ScannerTest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a number"); int a = sc.nextInt(); System.out.println("value = " + a); } } import java.util.Scanner; public class ScannerTest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a Characte..
백준 11654 자바 문제 아스키코드 변환 charAt은 int 인덱스를 지정할 수 있는 메소드다. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.next().charAt(0); System.out.println(a); } } charAt(0)이란 바로 첫번째 문자열만을 가져오겠다는 의미다. int a = sc.next().charAt(0); 그러니까 이 코드는 풀이하면, int a 라는 변수에 커맨드에서 입력될 문자열의 첫번째 문자를 대입하겠다는 것이다. charat은 string에서 문자를 가져오고 싶을 때 사용한다. 이 문제의 경우 입력이 숫자 0-..
Baekjoon 10870 Java Recursive Fibonacci number // Recursive method for getting the fibonacci number for N public static int Fibonacci(int N) { if(N == 0) return 0; if(N == 1) return 1; return Fibonacci(N-1) + Fibonacci(N-2); } import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); System.out.println(Fibonacci(N)); } // Recursive method for getting the ..
Baekjoon 10872 java factorial Recursive means, on a computer, repeatedly referring to yourself. Because it calls method inside the method, there are some problems to consider. If the recursive call becomes too repetitive, that is, when the recursive deepens, Java spits out an error called Stack Overflow. In the case of a recursive function, it eventually takes up a huge amount of memory because it is stacked in memory as muc..
LeetCode two sum brute force java This is the first time trying to solve leetcode but, I could only code 2 repeating for statements. and never could think of from if to return statement although when I saw the answer, it was easy to understand. I don't really think I understand how repeated for statement works and I will try to explain it to understand. for(int i=0;i
백준 15596번 자바 문제 문제를 아예 제대로 이해하지 못하고, 클래스를 만들려고 하고 있었고 다음이 결과다. import java.util.Scanner; public class Test { public static void main(String[] args) { //정수 n개가 주어졌을 때, n개의 합을 구하는 함수를 작성하시오. // //작성해야 하는 함수는 다음과 같다. // //Java: long sum(int[] a); (클래스 이름: Test) //a: 합을 구해야 하는 정수 n개가 저장되어 있는 배열 (0 ≤ a[i] ≤ 1,000,000, 1 ≤ n ≤ 3,000,000) //리턴값: a에 포함되어 있는 정수 n개의 합 Scanner sc = new Scanner(System.in); int N = sc.nextI..

반응형