분류 전체보기
-
chapter1) 양의 정수 자릿수 구하기PS/etc 2020. 7. 6. 20:57
public class Q11 { // 양의 정수를 입력하고 자릿수를 출력하는 프로그램 public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("자릿수를 구할 양의 정수를 입력하세요."); int a; do { System.out.print("a : "); a = scanner.nextInt(); } while (a 0) { a /= 10; num++; } System.out.println("자릿수 : " + num); } } - 풀다가 모르겠어서 답 봄 ※참조 Do it! 자료구조와 함께 배우는 알고리즘 입문
-
chapter1) 두 수의 차 구하기PS/etc 2020. 7. 6. 20:44
public class Q10 { // b-a = ? public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("두 수의 차를 구합니다."); System.out.print("a : "); int a = scanner.nextInt(); int b; do { System.out.print("b : "); b = scanner.nextInt(); } while (b a) break; System.out.println("a보다 큰 값을 입력하세요!"); } System.out.println("b - a는 " + (b - a) + "입니다."); } } (2) ※참조 Do it! 자료구..
-
chapter1) 두 정수 사이의 합 구하기PS/etc 2020. 7. 6. 20:01
public class Q9 { // 정수 a,b를 포함하여 그 사이의 모든 정수의 합 구하기 public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("두 수를 입력하세요."); System.out.print("a : "); int a = scanner.nextInt(); System.out.print("b : "); int b = scanner.nextInt(); int sum = sumof(a, b); System.out.println("sum : " + sum); } static int sumof(int a, int b) { int sum = 0; int max = 0; i..
-
-
SpringApplication - 2Spring 2020. 7. 6. 17:30
1) ApplicationEvent 등록 - ApplicationContext를 만들기 전에 사용하는 리스너는 @Bean으로 등록할 수 없다. - SpringApplication.addListners() 2) WebApplicationType 설정 3) 애플리케이션 아규먼트 사용하기 - ApplicationArguments를 빈으로 등록해 주니까 가져다 쓰면 된다. 4) 애플리케이션 실행한 뒤 뭔가 실행하고 싶을때 - ApplicationRunner (추천) 또는 CommandLineRunner - 순서 지정 가능 @Order (1) ApplicationContext가 만들어지기 전에 시작되는 이벤트는 빈으로 등록되어있더라도 실행되지 않는다. 해결법은 context에 직접 listener를 추가해준다. ..