Nightly 64비트
한국어 언어팩
버튼 클릭
general.useragent.locale 검색
더블클릭하고 ko-KR로 바꿈
파이어폭스 나이틀리 다시시작
Nightly 64비트
한국어 언어팩
버튼 클릭
general.useragent.locale 검색
더블클릭하고 ko-KR로 바꿈
파이어폭스 나이틀리 다시시작
외부로그인에서 win_password_forget() 함수는
win_password_lost()로 바꾸기
그누보드 아이디/비밀번호 찾기 (0) | 2014.10.10 |
---|---|
WEB DATA BASE의 개념 (0) | 2014.10.10 |
FTP (0) | 2014.09.30 |
그누보드를 이용한 최신 게시물 작성 방법 (0) | 2014.09.30 |
그누보드 폴더 파일구조 (0) | 2014.09.13 |
안드로이드 단말의 OS는 Linux 입니다.
Recursion
fibonacci(5)
Method Calls Resulting
from fibonacci(5)
import javax.swing.*; import java.util.*; public class Fig_5_6_P257 { //public static int length(String str) { public static int fibonacci(int n) { //if (str == null || str.equals("")) /* if (n==1) return 1; else if (n ==2) return 1; else retrun fibonacci(n-1) + fibonacci(n-2); */ if (n <= 2) return 1; // return 0; else return fibonacci(n - 1) + fibonacci(n - 2); //return 1 + length(str.substring(1)); } public static void main(String[] args) { //int n = length("ace"); int f = fibonacci(5); //System.out.println(n); System.out.println(f); } }
Recursion 2 (0) | 2014.10.18 |
---|---|
Recursion 1 (0) | 2014.10.18 |
Palindrome (0) | 2014.10.18 |
Queue (0) | 2014.10.18 |
Stack (0) | 2014.10.18 |
Recursion
factorial(4)
Trace of factorial(4)
import javax.swing.*; import java.util.*; public class Fig_5_5_P253 { //public static int length(String str) { public static int factorial(int n) { //if (str == null || str.equals("")) if (n == 0) return 1; // return 0; else return n * factorial(n - 1); //return 1 + length(str.substring(1)); } public static void main(String[] args) { //int n = length("ace"); int f = factorial(4); //System.out.println(n); System.out.println(f); } }
Recursion 3 (0) | 2014.10.18 |
---|---|
Recursion 1 (0) | 2014.10.18 |
Palindrome (0) | 2014.10.18 |
Queue (0) | 2014.10.18 |
Stack (0) | 2014.10.18 |
Recursion
length("ace")
Trace of length("ace")
Trace of length("ace")
Using Activation
Frames
import javax.swing.*; import java.util.*; public class Fig_5_4_P251 { public static int length(String str) { if (str == null || str.equals("")) return 0; else return 1 + length(str.substring(1)); } public static void main(String[] args) { int n = length("ace"); System.out.println(n); } }
Recursion 3 (0) | 2014.10.18 |
---|---|
Recursion 2 (0) | 2014.10.18 |
Palindrome (0) | 2014.10.18 |
Queue (0) | 2014.10.18 |
Stack (0) | 2014.10.18 |
Palindrome
import javax.swing.*; import java.util.*; public class PalindromeFinder_1 { //public static void main(String[] args) { //List<String> myList = new ArrayList<String>(); //Stack<String> names = new Stack<String>(); private String inputString; private Stack<Character> charStack = new Stack<Character>(); public PalindromeFinder_1(String str) { inputString = str; fillStack(); } private void fillStack() { for (int i = 0; i < inputString.length(); i++) charStack.push(inputString.charAt(i)); } private String buildReverse() { StringBuilder result = new StringBuilder(); while (!charStack.empty()) result.append(charStack.pop()); return result.toString(); } public boolean isPalindrome() { return inputString.equalsIgnoreCase(buildReverse()); } public static void main(String[] args) { //PalindromeFinder palindr = new PalindromeFinder("abc"); String str = JOptionPane.showInputDialog(" Strng :"); PalindromeFinder_1 palindr = new PalindromeFinder_1(str); boolean bPalindr = palindr.isPalindrome(); //System.out.println(bPalindr); if (bPalindr) System.out.println(str + " : palindrome"); else System.out.println(str + " : not palindrome"); } }
Recursion 2 (0) | 2014.10.18 |
---|---|
Recursion 1 (0) | 2014.10.18 |
Queue (0) | 2014.10.18 |
Stack (0) | 2014.10.18 |
The ListIterator (0) | 2014.10.18 |
Queue
새로운 Queue names를 선언한다.
Queue<string> names = new LinkedList<string>();
Method |
Behavior |
boolean offer(E item) |
큐의 뒤쪽에 item을 삽입한다. 성공하면 true를 반환, item이 삽입되지 못하면 false. |
E remove() |
큐의 맨 앞부분을 제거하고 만약 큐가 비지 않았으면 그것을 반환, 비었으면 예외 발생 |
E poll() |
큐의 맨 앞부분을 제거하고 반환한다. 큐가 비었으면 null을 반환 |
E peek() |
큐의 맨 앞을 제거하지 않고 반환. 큐가 비었으면 null을 반환 |
E element() |
큐의 맨 앞을 제거하지 않고 반환, 큐가 비었으면 예외 발생 |
import javax.swing.*; import java.util.*; public class Self_Check_4_1_1_P199 { public static void main(String[] args) { // Queue<String> names = new LinkedList<String>(); Queue<String> customers = new LinkedList<String>(); customers.offer("Thome"); customers.offer("Abreu"); customers.add("Jones"); customers.add("Harris"); String first = customers.peek(); System.out.println("Front(peek) = " + first); first = customers.element(); System.out.println("Front(element) = " + first); String temp = customers.remove(); System.out.println("Front(remove) = " + temp); temp = customers.poll(); System.out.println("Front(poll) = " + temp); int n = customers.size(); System.out.println(n); while(!customers.isEmpty()) System.out.println(customers.remove()); } }
import javax.swing.*; import java.util.*; public class Self_Check_4_1_3_P200 { public static void main(String[] args) { //Queue<String> names = new LinkedList<String>(); Queue<String> myQueue = new LinkedList<String>(); //names.offer("Thome"); myQueue.offer("Hello"); myQueue.offer("Bye"); System.out.println(myQueue.peek()); myQueue.remove(); myQueue.offer("Welcome"); if (!myQueue.isEmpty()) System.out.println(myQueue.remove() + ", Size : " + myQueue.size() + ", Front : " + myQueue.peek()); while(!myQueue.isEmpty()) System.out.println(myQueue.remove()); } }
Recursion 1 (0) | 2014.10.18 |
---|---|
Palindrome (0) | 2014.10.18 |
Stack (0) | 2014.10.18 |
The ListIterator (0) | 2014.10.18 |
The Iterator (0) | 2014.10.16 |
Stack
Stack
Methods |
Behavior |
boolean empty() |
스택이 비었으면 true, 아니면 false. |
peek() |
스택의 가장 위의 객체를 제거하지 않고 반환 |
pop() |
스택의 가장 위의 객체를 반환하고 제거 |
push(E obj) |
스택의 가장 위에 아이템을 넣고 넣은 아이템 반환 |
스택 names (type Stack<String>) 는 그림(a)와 같이 5개의 문자열을 포함하고 있다.
"Rich"는 스택에서 다른 4개의 이름 뒤에 위치해 있다.
"Jonathan"은 스택에서 가장 마지막 요소이다.
그림 (a) 에서 names.empty()의 값은 false 이다.
String last = names.peek();
위 문은 names의 변화 없이 last에 "Jonathan"을 저장한다.
String temp = names.pop();
위 문은 스택 names로 부터 "Jonathan"을 제거하고 temp에 저장한다.
이제 스택 names는 그림(b)처럼 4개의 요소를 포함하고 있다.
names.push("Philip");
위 문은 "Philip"을 스택 위로 넣는다. 이제 스택 names는 그림(c)처럼 다섯개의 요소를 가지고 있다.
스택 names를 그림(c)에서와 같이 정의 된 것으로 가정하고, 뒤따르는 연산의 배열을 수행한다. 각 연산의 결과를 나타내며, 만약 변경이 되면 새 스택을 나타내라.
names.push("Jane");
names.push("Joseph");
String top = names.pop();
String nextTop = names.peek();
그림(c)
names.push("Jane");
names.push("Joseph");
String top = names.pop();
String top 은 "Joseph"을 포함한다.
String nextTop = names.peek();
String nextTop는 "Jane"을 포함하고 변화 x
import javax.swing.*; import java.util.*; public class Ex_3_1_1_P152 { public static void main(String[] args) { Stacknames = new Stack (); names.push("Rich"); names.push("Debbie"); names.push("Robin"); names.push("Dustin"); names.push("Jonathan"); String last = names.peek(); System.out.println("Top = " + last); String temp = names.pop(); System.out.println("Top(pop) = " + temp); last = names.peek(); System.out.println("Top = " + last); names.push("Philip"); last = names.peek(); System.out.println("Top = " + last); //Exercises for Section 3.1 names.push("Jane"); names.push("Joseph"); String top = names.pop(); String nextTop = names.pop(); // String nextTop = names.peek(); System.out.println(top + " - " + nextTop); System.out.println(names.peek()); } }
Palindrome (0) | 2014.10.18 |
---|---|
Queue (0) | 2014.10.18 |
The ListIterator (0) | 2014.10.18 |
The Iterator (0) | 2014.10.16 |
The LinkedList Class (0) | 2014.10.16 |
The ListIterator
ListIterator는 Iterator와 다르게 양방향으로 접근이 가능하다.
import javax.swing.*; import java.util.*; public class LinkedList_Ex_2_13_P108 { public static void main(String[] args) { LinkedList<String> myList = new LinkedList<String>(); myList.addFirst("Sam"); System.out.println("size = " + myList.size()); myList.addFirst("Harry"); System.out.println("size = " + myList.size()); myList.addFirst("Dick"); System.out.println("size = " + myList.size()); myList.addFirst("Tom"); System.out.println("size = " + myList.size()); int n = myList.size(); for (int i = 0; i < n; i++) System.out.print(myList.get(i) + "\t"); System.out.println("n = " + n); ListIterator<String> myIter = myList.listIterator(2); System.out.println(myIter.hasPrevious()); System.out.print(myIter.previousIndex() + "\t" + myIter.nextIndex() + "\t"); System.out.println(myIter.next()); System.out.print(myIter.previousIndex() + "\t" + myIter.nextIndex() + "\t"); System.out.println(myIter.next()); System.out.println(myIter.hasNext()); System.out.print(myIter.previousIndex() + "\t" + myIter.nextIndex() + "\t"); System.out.println(myIter.previous()); System.out.print(myIter.previousIndex() + "\t" + myIter.nextIndex() + "\t"); System.out.println(myIter.previous()); while(myIter.hasNext()) { System.out.print(myIter.nextIndex() + "\t"); System.out.println(myIter.next()); } } }
Queue (0) | 2014.10.18 |
---|---|
Stack (0) | 2014.10.18 |
The Iterator (0) | 2014.10.16 |
The LinkedList Class (0) | 2014.10.16 |
Applications of ArrayList (0) | 2014.10.16 |