본문 바로가기

취업준비 - 코테 , 면접/알고리즘(코테) 공부

(104)
백준 9498번 (조건문) 풀이. import java.util.*; class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int A = sc.nextInt(); if(A>=90){ System.out.println("A"); } else if(A>=80){ System.out.println("B"); } else if(A>=70){ System.out.println("C"); } else if(A>=60){ System.out.println("D"); } else{ System.out.println("F"); } } }
백준 1330번 (조건문) 풀이) import java.util.*; class Main { public static void main(String[] args){ Scanner in=new Scanner(System.in); int A = in.nextInt(); int B = in.nextInt(); System.out.println((A>B) ? ">" : ((A
알고리즘 입문(Java) - String - 4.단어뒤집기 풀이1. import java.util.*; class Main { public ArrayList solution(int n, String[] str){ ArrayList answer=new ArrayList(); for(String x : str){ String tmp=new StringBuilder(x).reverse().toString(); answer.add(tmp); } return answer; } public static void main(String[] args){ Main T = new Main(); Scanner kb = new Scanner(System.in); int n=kb.nextInt(); String[] str=new String[n]; for(int i=0; i
알고리즘 입문(Java) - String - 2.대소문자 변환 풀이 import java.util.*; class Main { public String solution(String str){ String answer=""; for(char x : str.toCharArray()){ if(Character.isLowerCase(x)) answer+=Character.toUpperCase(x); else answer+=Character.toLowerCase(x); } return answer; } public static void main(String[] args){ Main T = new Main(); Scanner kb = new Scanner(System.in); String str=kb.next(); System.out.print(T.solution(str));..
알고리즘 입문(Java) - String - 1. 문자 찾기 풀이 import java.util.*; class Main{ public int solution(String str, char t){ int answer=0; str=str.toUpperCase(); t=Character.toUpperCase(t); for(int i=0; i
백준 2588번 (입출력과 사칙연산)
백준 10430번 (입출력과 사칙연산)
백준 3003번 (입출력과 사칙연산) 소스코드 * 출처 : https://chung-develop.tistory.com/101 * throws 용법에 대해 처음 알게 되서 공부해 보았다. throws는 예외를 넘기고 try~catch는 예외를 처리한다는 것을 알수 있었다. 또 throws는 예외 발생 이후의 코드는 실행하지 않고, try~catch는 예외 발생 이후의 코드를 실행한다는 점도 알았다. (관련 링크 : https://go-coding.tistory.com/10 )