본문 바로가기

독학3

[백준] 1157번 문자열 '단어공부' package backjun; import java.io.*; public class Ex1157 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String S; int[] a = new int[26]; S = br.readLine(); for(int i=0; i=65 && t 2022. 3. 31.
[알고리즘 독학] 스택(Stack) 스택 데이터를 일시적으로 저장하기 위한 자료구조 가장 나중에 넣은 데이터를 가장 먼저 꺼냅니다. 스택만들기 스택 본체용 배열 : stk 스택 용량 : max 스택 포인터 : ptr 생성자 IntStack 푸시 메서드 push -스택이 가득차서 푸시 할 수 없는 경우 예외 OverflowIntStackException을 던집니다. 팝 메서드 pop -스택이 비어 있어 팝을 할 수 없는 경우 EmptyIntStackException을 던집니다. 피크 메서드 peak -꼭대기에 있는 데이터를 “몰래 엿보는” 메서드 -스택이 비어 있는 경우 예외 EmptyIntStackException을을 던집니다. 검색 메서드 indexOf -검색을 성공면 찾아낸 요소의 인덱스를 반환하고 실패하면 -1을 반환합니다. 스택의 .. 2022. 3. 29.
[백준] 10809번 알파벳 찾기 import java.util.Scanner; public class Ex10809 { public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] std = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; String a = in.next(); in.close(); String result = ""; int k = -1; for(int i = 0; i < std.length; i++) { k = -1; for(int j = 0; j < a.length(); j++) { i.. 2022. 3. 28.