별의 공부 블로그 🧑🏻‍💻

🗒️ Source Code (118)

728x90
  1. 2017.05.21 문자 객체

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 var t="Hello Thank You good luck to you"; document.write(t.charAt(16), " "); // 인덱스 16에 저장된 문자를 볼러옴. -> "g" document.write(t.indexOf("you",16), " "); // 문자열 왼쪽에서부터 최초로 발견된 "you"의 인덱스 값을 반환함. -> 12 document.write(t.lastIndexOf("you"), " "); // 문자열 인덱스 16 위치부터 최초로 발견된 "you"의 인덱스 값을 반환함. -> 29 document.write(t.alstIndexOf("y..

  2. 2017.05.21 배열 객체

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 var d=[30, "홍기동", true]; document.write(d[0], " "); document.write(d[1], " "); document.write(d[2], " "); for(var i=0; i var greenLine=["사당","교대","방배","강남"]; var yellowLine=["미금","정자","모란","수서"]; greenLine.spl..

  3. 2017.05.21 수학 객체

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 var num=2.1234; var maxNum=Math.max(10, 5, 8, 20); // 최댓값 반환 var minNum=Math.min(10, 5, 8, 20); // 최솟값 반환 var roundNum=Math.round(num); // 반올림 값 반환 var floorNum=Math.floor(num); // 소수점에서 무조건 내림 var ceilNum=Math.ceil(num); // 소수점에서 무조건 올림 var rndNum=Math.random(); // 0~1 사이의 난수 발생 var piNum=Math.PI; // 원주율 상수 반환 document.write(maxNum, " ");..

  4. 2017.05.21 숫자 객체

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 var num=3.456784; var num2=70000; var num3="30.5px"; var num4=40; document.write("표현 가능한 가장 큰 수:"+Number.MAX_VALUE, " "); document.write("표현 가능한 가장 작은 수:"+Number.MIN_VALUE, " "); document.write("숫자가 아닌 경우의 표기:"+Number.NaN, " "); document.write("무한대 수 표기:"+Number.POSITIVE_INFINITY, " "); document.write("음의 무한대 수 표기:"+Number.NEGATIVE_INFINITY, " "..

  5. 2017.05.21 날짜 정보 객체

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 var tv=new Object(); tv.width="30cm"; tv.height="25cm"; tv.weight="20kg"; tv.color="white"; tv.off=function(){ document.write("전원 off", " "); } document.write(tv.width, " "); document.write(tv.height, " "); document..

  6. 2017.05.21 현재 연도와 월에 해당하는 전체 일자 출력

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 var year=prompt("현재 몇 년입니까?","0000"); var mon=prompt("현재 몇 월입니까?", "0"); var last_day; switch(mon){ case "1": last_day=31; break; case "2": last_day=28; /* 현재 연도가 4년 주기이고 100년 주기는 아닌경우 또는 400년 주기로 윤년. 윤년은 2월은 ..

  7. 2017.05.21 구구단 출력 프로그램

    1 2 3 4 5 6 7 8 9 for(var i=2; i

  8. 2017.05.21 Boolean/Typeof/Texttable/If/For/While/Switch/Confirm Test

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12..

  9. 2017.05.21 간단한 실행문

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 맛보기 예제 // 지바스크립트 선언문 var age = prompt("당신의 나이는?", "0"); // 질의 응답 창을 띄움 if(age>=20) { document.write("당신은 성인입니다."); } else { document.write("당신은 미성년자입니다."); } document.write("welcome!"); console.log("javascript"); //* 자바스크립트 실행문; Colored by Color Scripter cs 소스 출처 : Do It! 자바스크립트+제이쿼리 입문 (정인용 지음, 이지스퍼블리싱)

  10. 2017.05.18 입출력 (INPUT / OUTPUT)

    ;; INPUT/OUTPUT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; WITH-OPEN-FILE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Opening file for output ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun get-tree-data () (with-open-file (stream "timber.txt") (let* ((tree-loc (read stream)) (tree-table (read stream)) (num-trees (read str..

  11. 2017.05.16 중위 표기 수식을 후위 표기 수식으로 변환하는 프로그램

    123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107// 중위 표기 수식을 후위 표기 수식으로 변환하는 프로그램 #include #include #define MAX_STACK_SIZE 100 typedef char element; typedef struct { element stack[MAX_STACK_SIZE]; int top;} StackType; // 스택 초기화 함수voi..

  12. 2017.05.16 후위 표기식 계산 프로그램 5

    - 수식을 표기하는 방법에는 중위(infix), 후위(postfix), 전위(prefix)의 3가지 방법이 있음.- 연산자가 피연산자 사이에 있으면 중위이고, 연산자가 피연산자 뒤에 있으면 후위이며, 연산자가 피연산자 앞에 있으면 전위라고 함.- 인간은 주로 중위 표기법을 사용하지만 컴파일러는 주로 후위 표기법을 사용함.- 후위 표기 수식은 괄호가 없어도 우선순위가 반영되어 있음. 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485// 후위 표기식 계산 #include ..

  13. 2017.05.16 순환 (Recursion)

    ;; Recursion (defun anyoddp (x) (cond ((null x) nil) ((oddp (first x)) t) (t (anyoddp (rest x))))) (defun fact (n) (cond ((zerop n) 1) (t (* n (fact (- n 1)))))) (defun count-slices (loaf) (cons ((null loaf) 0) (t (+ 1 (count-slices (rest loaf)))))) ;; Double-Test Tail Recursion (defun func (x) (cond (end-test-1 end-value-1) (end-test-2 end-value-2) (t (func reduced-x)))) (defun anyoddp (x) (con..

  14. 2017.05.11 괄호 검사 프로그램

    12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697// 괄호 검사 프로그램 #include #include #define TRUE 1#define FALSE 0#define MAX_STACK_SIZE 100 typedef char element; typedef struct { element stack[MAX_STACK_SIZE]; int top;} StackType; // 스택 초기화 함수void init(StackType *s..

  15. 2017.05.09 리스트뷰 (ListView) 사용 예시 3

    1. MainActivity.java 123456789101112131415161718192021package ... import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.widget.ListView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listView = (ListView) fin..

  16. 2017.05.09 리스트뷰 (ListView) 사용 예시 2

    1. MainActivity.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 package org.androidtown.javaandandroidchap14; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ArrayAdapter; import android.widget.ListView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate..

  17. 2017.05.09 리스트뷰 (ListView) 사용 예시 1

    1. MainActivity.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 package org.androidtown.javaandandroidchap14; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ListView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.lay..

  18. 2017.05.09 프레임 레이아웃을 이용한 버튼 클릭 시 그림 전환

    1. MainActivity.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 package ... import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { ..

  19. 2017.05.08 연결 리스트로 구현된 리스트 ADT 테스트 프로그램

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12..

  20. 2017.05.08 이중 연결 리스트의 다항식 프로그램

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 #include #include // 연결 리스트의 노드의 구조 typedef struct..

  21. 2017.05.07 스택 (Stack) & 큐 (Queue)

    1. MainActivity.class 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687package ... import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import android.widget.EditText; import java.util.Stack;import java.util...

  22. 2017.05.06 버튼을 누를 때 마다 스크롤뷰에 담겨진 레이아웃에 텍스트뷰 넣는 방법

    1. MainActivity.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 package ... import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.AppCompatActiv..

  23. 2017.05.05 화면이 터치되었을 때, X 좌표 및 Y 좌표를 알아내는 방법

    1. MainActivity.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 package ... import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.MotionEvent; import android.view.View; import android.widget.EditText; import android.widget.FrameLayout; public class MainActivity extends AppCompatActivity { Ed..

  24. 2017.05.03 별 찍기 (Asterisk Decoration) in C

    [소스1] 1 2 3 4 5 6 7 8 9 10 11 12 13 #include int main(void) { int i, j; for (i = 1; i

  25. 2017.04.26 Multiplication Tables (9X9, 18X18) in C

    9 X 9 Multiplication Table 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include int main(void) { printf("Multiplication Table (9X9) \n"); for (int i = 0; i

  26. 2017.04.21 Checking whether an input element is a number or not with using DO macro. (Infinite Loop)

    (defun read-a-number () (do ((answer nil)) (nil) ; This is necessary to make Infinite Loop function. (format t "~&Please type a number: ") (setf answer (read)) (if (numberp answer) (return answer) (format t t "~&Sorry, ~S is not a number. Try again." answer)))) A Program which checks whether the input number is a number or not by using DO macro. If the input number is not a number, the program p..

  27. 2017.04.17 Numbers in Ascending/Descending Order with using Recrusion in C

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include void recur_print(int n) { recur_print(10); } // 10 9 8 7 6 5 4 3 2 1 void recur_print(int n) { if (n > 0) { printf("%d ", n); recur_print(n-1); } } // 1 2 3 4 5 6 7 8 9 10 void recur_print(int n) { int a; if (n > 0) { recur_print(n-1); printf("%d ", n); } } cs As you can see, if you put the part for recursion before you put the pa..

  28. 2017.04.17 Sum of Numbers in Ascending/Descending Order with using Recursion in C

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #include int print_sum(int n); void main() { printf(" = %d", print_sum(10)); } // 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 int print_sum(int n) { if (n

728x90


📖 Contents 📖