-
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)) ..
-
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
-
2017.05.30
인수와 레퍼런스
* 인수와 레퍼런스 - 포인터를 함수의 인수로 사용하면 호출자의 변수를 변경할 수 있음. - 하지만 포인터는 메모리 주소를 직접 다루기 때문에 어려움. - 레퍼런스(reference) : 변수등으로 초기화한 식별자. 형명 앞에 &를 붙여서 선언함. 형명& 레퍼런스명 = 변수; // 레퍼런스명에는 식별자를 사용함. int a; int& rA = a; // 레퍼런스 rA를 변수 a로 초기화함. -> 이 코드에서 'rA'가 레퍼런스. rA를 변수 a로 초기화한 것. - 예) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #include using namespace std; int main() { int a = 5; int& rA = a; // 레퍼런스 rA를 변수 ..