별의 공부 블로그 🧑🏻‍💻

🗒️ Source Code (118)

728x90
  1. 2017.09.14 배열 내에서 같은 수의 개수 찾기 (Finding the number of the same number in an array)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include int main() { int count = 0, input = 0; int ary[10] = {0, 1, 2, 3, 4, 4, 3, 2, 5, 6}; printf("Input a number : "); scanf("%d", &input); for(int i = 0; i

  2. 2017.06.08 Block's World

    ;;;; Block's World;; ;;;; Global Variables;; (defstruct blocks (name nil) (color nil) (ison 'table) (isunder nil)) (defvar *blocks*) ;;;; Main;; (defun start-world () (setf *blocks* nil)) (defun new-block (name color) (push (make-blocks :name name :color color) *blocks*)) (defun get-block (name) (dolist (x *blocks* nil) (if (equal name (blocks-name x)) (return x)))) (defun clear-top? (name) (if ..

  3. 2017.05.31 원형 큐 (Circular Queue) 예

    123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106// 원형 큐 예 #include #include typedef int element;typedef struct { element *queue; int front, rear; int size;} QueueType; void init(QueueType *q) { q->front = q->rear = 0; q->size = 2; // 원형..

  4. 2017.05.31 중위 표기 수식을 전위 표기 수식으로 변환하는 프로그램

    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..

  5. 2017.05.31 samesetp

    (defun samesetp (lis1 lis2) (if (and (not (null lis1)) (not (null lis2))) (let ((x (first lis1)) (y (first lis2))) (cond ((and (listp x) (listp y)) (and (samesetp x y) (samesetp (rest lis1) (rest lis2)))) (t (and (eq x y) (samesetp (rest lis1) (rest lis2)))))) (= (length lis1) (length lis2)))) (defun samesetp (lis1 lis2) "Another Version of samesetp." (if (null lis1) (null lis2) (let ((x (remove..

  6. 2017.05.30 Tic Tac Toe Game

    ;; Defining global varaibles and constants (defconstant One 1) ;; human(defconstant TheOther 10) ;; computer (defvar *Opponent* One)(defvar *Computer* TheOther) (defvar *Triplets* '((1 2 3) (4 5 6) (7 8 9) ;; Horizontal Line (1 4 7) (2 5 8) (3 6 9) ;; Vertical Line (1 5 9) (3 5 7))) ;; Diagonal Line ;; Main ;; Initialization: Creating a board (defun makeBoard () (list 'Board 0 0 0 0 0 0 0 0 0)) ..

  7. 2017.05.30 배열 요소 정리

    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 #include using namespace std; int main() { const int num =5; int test[num]; cout

  8. 2017.05.25 Ajax로 RSS 연동하기

    - RSS(Really Simple Syndication)란, 사전저긍로 '초간편 배급(배포)'이라는 의미를 가지고 있음. - 자주 업데이트되는 뉴스나 신문 기사 내용을 사용자에게 쉽게 배포하기 위해 만들어진 XML 기반의 배급 포맷. - 크로스 도메인이란 도메인이 서로 다를 경우에 정보 교환을 하지 못하도록 한 보안 정책을 의미하며, 이를 해결할 수 있는 방법으로는 구글에서 제공하는 Google Feed API link(데이터 전환 전송 기능)을 이용하는 것이 있음. 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 4..

  9. 2017.05.22 주요 선택자 정리

    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 div{background-color:yellow;} .tit{background-color:orange;} 내용1 내용2 내용3 내용4 리스트1 리스트2 리스트3 리스트4 $(function(){ $("h1").attr("align","left"); // 태그의 "align" 속성값을 "left"로 적용 $("li:first").text("첫 번째 리스트"); // 태그 중에 첫 번째 요소의 텍스트를 새 텍스트로 바꿈. $("h2>strong"..

  10. 2017.05.22 아이디 선택자를 적용하여 글자 색상을 바꾸기

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 선택자 $(function(){ $("#title").css("color","green"); }); 제이쿼리 Colored by Color Scripter cs 소스 출처 : Do It! 자바스크립트+제이쿼리 입문 (정인용 지음, 이지스퍼블리싱)

  11. 2017.05.21 이벤트 객체 (Event Object)

    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 document.onkeydown=function(e){ alert(e); } document.onkeydown=function(e){ alert(window.event); } document.onkeydown=function(e){ var ev..

  12. 2017.05.21 this를 사용한 이벤트

    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 이벤트 function chColor(obj, state){ var myColor; if(state=="over"){ myColor="red"; } else { myColor="black"; } obj.style.color=myColor; } // 에 마우스를 올릴 경우엔 글자 색상이 빨간색으로 바..

  13. 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 window.onload=function(){ function fnc1(){ alert('실행문1'); } function fnc2(){ alert('실행문2'); } var myBtn=document.getElementById("btn"); if(window.addEventListener) { // 파이어폭스, 크롬 등 브라우저에서 true를 반환하여 조건식을 만족 myBtn.addEventListener("click",fnc1,false); myBtn.addEventListener("click",fnc2,false); } else { // IE 8 이하에서만 실행..

  14. 2017.05.21 이벤트 (Event)

    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 color=["white","yellow","aqua","purple"]; var i=0; function colorBg(){ i++; if(i>=color.length) i=0; var bodyTag=document.getElementByTagName("body")[0]; bodyTag.style.backgroundColor=color[i]; } window.onload=f..

  15. 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 window.onload=function(){ var list_zone=document.getElementById("inner_list"); var list_zone,getElementsByTagName("a"); for(var i=0; i=list_a.length-3) return false; m_num++; list_zone.style.marginLeft=100*m_num+"px"; return false; } var n_btn=document.getElementById("before_btn"); n_btn.onclick=funct..

  16. 2017.05.21 함수 (Function) 1

    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 var i=0; function myFnc(){..

  17. 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 function(){ var basic_car=Number(document.getElementById("total").defaultValue); for(var i=1; i

  18. 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 회원 로그인 아이디 비밀번호 document.f1.onsubmit=function(){ var pw1=document.f1.user_pw1; var pw2=document.f1.user_pw2; pw2.value=pw1.value; pw2.disabled=true; return false; } document.f2.allChk.onclick=function(){ if(this.checked) { document.f2.subject1.checked=true; document..

  19. 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 ... 마우스 아웃 var theBtn=document.getElementById("btn"); var s=document.getElementById("img_src"); theBtn.onmouseover=function(){ document.getElementById("title").innerHTML="마우스 오버"; theBtn.firstChild.src="images/btn_over.gif"; s.innerHTML=theBtn.firstChild.src; } theBtn.onmouseout=function(){ document.getElementById("title").inne..

  20. 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 .... 내용1 내용2 내용3 내용4 document.getElementById("wrap").children[0].style.color="red"; var p=document.getElementsByTagName("p")[1]; var nextObj=p.nextSibling; while(nextObj.nodeType != 1) { nextObj=nextObj.nextSibling; } nextObj.style.backgroundColor="yellow"; Colored by Color Scripter cs 소스 출처 : Do It! 자바스크립트+제이쿼리 입문 (정인용 지음, 이지스퍼블리싱)

  21. 2017.05.21 문서 객체 모델 (DOM)

    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 DOM 객체 선호하는 음식 한식 김치 불고기 비빔밥 양식 돈까스 피자 파스타 document.getElementsByTagName("h1")[0].style.color="green"; document.getElementById("title").style.color="red"; var myList=document.getElementById("food_1").getElementsByTa..

  22. 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 function info1() { var os=navigator.userAgent.toLowerCase(); var info_wrap=document.getElementById("info_wrap"); if(os.indexOf('windows')>=0) { info_wrap.innerHTML="윈도우"; } else if(os.indexOf('macintosh')>=0) { info_wrap.innerHTML="맥킨토시"; } else if(os.indexOf('iphone')>=0) {..

  23. 2017.05.21 navigator 객체

    1 2 3 4 5 6 7 8 9 10 document.write("appCodeName: "+navigator.appCodename," "); document.write("appName: "+navigator.appName," "); document.write("appVersion: "+navigator.appVersion," "); document.write("language: "+navigator.language," "); document.write("product: "+navigator.product," "); document.write("platform: "+navigator.platform," "); document.write("userAgent: "+navigator.userAgent," ")..

  24. 2017.05.21 history 객체

    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 첫 페이지 2페이지 이동 두 번째 페이지 3페이지 이동 이전 페이지> 다음 페이지 세 번째 페이지 1단계 이전 페이지 2단계 이전 페이지 Colored by Color Scripter cs 소스 출처 : Do It! 자바스크립트+제이쿼리 입문 (정인용 지음, 이지스퍼블리싱)

  25. 2017.05.21 location 객체

    1 2 3 4 5 6 7 8 document.write("href: "+location.href, " "); document.write("hash: "+location.hash, " "); document.write("hostname: "+location.hostname, " "); document.write("host: "+location.host, " "); document.write("protocol: "+location.protocol, " "); Colored by Color Scripter cs 소스 출처 : Do It! 자바스크립트+제이쿼리 입문 (정인용 지음, 이지스퍼블리싱)

  26. 2017.05.21 screen 객체

    1 2 3 4 5 6 7 8 document.write("width: "+screen.width, " "); document.write("height: "+screen.height, " "); document.write("availWidth: "+screen.availWidth, " "); document.write("availHeight: "+screen.availHeight, " "); document.write("colorDept: "+screen.colorDepth, " "); Colored by Color Scripter cs 소스 출처 : Do It! 자바스크립트+제이쿼리 입문 (정인용 지음, 이지스퍼블리싱)

  27. 2017.05.21 window 객체

    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 window 객체 *{margin:0; padding:0;} window 객체 window.open("winpopup.html","pop1","width=300, height=400, left=300, top=10, scrollbars=no, toolbars=no, location=no"); 이지 window 객체..

  28. 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 var date=new Date(); var y=date.getFullYear(); var m=date.getMonth(); var d=date.getDay(); var theDate=new Date(y,m,1); var theDay=theDate.getDay(); var last=[31,28,31,30,31,30,31,31,30,31,30,31]; if(y%4&&y%100!=0 || y%400==0) lastDate=last[1]=2..

  29. 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 var str="Html Css Jquery"; var reg1=/css/; // var reg1=new RegExp)("css") // 변수 str에 데이터가 reg1에 정규 표현 규칙을 잘 지켰으면 true를 반환하고, 안 지켰을 경우에는 false를 반환함. var result_1=reg.test(str); document.write(result_1, " "); // 옵션에 'i'를 입력하면 영문 대소문자를 구분하지 않음. var reg2=/css/i..

  30. 2017.05.21 이메일 유효성 검사

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 var userEmail=prompt("당신의 이메일 주소는?", ""); var arrUrl=[".co.kr",".com",".net",".or.kr","go.kr"]; var check1=false; var check2=false; if(userEmail.indexOf("@")>0) check1=true; for(var i=0; i0) check2=true; } if(check1&&check2) { document.write(uderEmail); } else { alert("이메일 형식이 잘못되었습니다."); } Colored by Color Scripter cs 소스 출처 : Do It! 자바스크립트+제..

728x90


📖 Contents 📖