JAVA/Coding Test Study151 [D1] SWEA - 1936. 1대1 가위바위보 : Java A가 이기는 경우들만 처리하고 나머지 경우는 else로 묶어 B가 이긴 것으로 했다 import java.util.Scanner;import java.io.FileInputStream;class Solution{ public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int A = sc.nextInt(); int B = sc.nextInt(); if (A== 1 && B == 3) { System.out.println("A"); } else if (A == 2 && B == 1) { System.out.println("A"); } else if (.. 2023. 11. 18. [D1] SWEA - 2058. 자릿수 더하기 : Java 습관처럼 for을 쓰려다 while로 다시 작성했다 import java.util.Scanner;import java.io.FileInputStream;class Solution{ public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sum = 0; while(n > 0) { sum += n % 10; n /= 10; } System.out.println(sum); }} 2023. 11. 18. [D1] SWEA - 2043. 서랍의 비밀번호 : Java for문을 사용해서 풀어보려다가 계속 fail이 났던 문제...이렇게 쉬운 방법이 있는데 for문에 꽂혀서 생각을 못했다 import java.util.Scanner;import java.io.FileInputStream;class Solution{ public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int P = sc.nextInt(); int K = sc.nextInt(); System.out.println(P-K+1); }} for을 사용해서 다시 풀어보았다! import java.util.Scanner.. 2023. 11. 18. [D1] SWEA - 2025. N줄덧셈 : Java 처음으로 바로 푼 문제! import java.util.Scanner;import java.io.FileInputStream;class Solution{ public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sum = 0; for(int i = 1; i 2023. 11. 18. [D1] SWEA - 1938. 아주 간단한 계산기 : Java nextInt가 바로 생각이 안 날 수가 있나? 공부한게 다 어디로 간 건지 ㅎㅎ...내 공부 방법이 잘못됐었나 싶다 import java.util.Scanner;import java.io.FileInputStream;class Solution{ public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a + b); System.out.println(a - b); .. 2023. 11. 18. [D1] SWEA - 2047. 신문 헤드라인 : Java 알고 있는 함수인데도 이렇게 생각이 안 나다니... 반성😢 import java.util.Scanner;import java.io.FileInputStream;class Solution{ public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); str = str.toUpperCase(); System.out.println(str); }} 2023. 11. 18. 이전 1 ··· 22 23 24 25 26 다음