diff --git a/homework4.txt b/homework4.txt index d8160f0..fc50aad 100644 --- a/homework4.txt +++ b/homework4.txt @@ -1,2 +1,10 @@ 1. What is .gitignore? You can write the answer either in Korean or English. -2. Why do Github users need an SSH key pair? (Users can use either SSH key pair or github account info.) Please write down a brief explanation of SSH key. \ No newline at end of file + +$ git add 라는 커멘드로 파일을 track하는데, 이때 track할 필요가 없거나 제외하고 싶은 일부 파일들의 목록을 기록하는 파일이다. +프로젝트의 최상단, 즉 $ git init 한 디렉토리에 .gitignore이라는 파일을 만들고, 관리에서 제외할 파일들의 파일명을 입력하면 된다. + + +2. Why do Github users need an SSH key pair? (Users can use either SSH key pair or github account info.) Please write down a brief explanation of SSH key. + +Github상의 내 repository를 타인이 함부로 수정하지 못하도록 push 권한을 부여하기 위한 비밀번호가 SSH key이다. +SSH key는 서버상에 위치하는 공개키(public key)와 클라이언트(내 컴퓨터)상에 위치하는 비공개키(private key)로 이루어져 있으며, SSH 접속을 시도할 때 이 둘이 일치하면 접근을 허가한다. \ No newline at end of file diff --git a/homework4/Source.cpp b/homework4/Source.cpp index ab69b66..61c04e0 100644 --- a/homework4/Source.cpp +++ b/homework4/Source.cpp @@ -9,7 +9,7 @@ int main() const int arrsize = 10; int* arr = new int[arrsize]; srand((unsigned int)time(NULL)); - cout << "Array arr: " ; + cout << "Array arr: "; for (int i = 0; i < arrsize; i++) { arr[i] = (rand() % 10); @@ -17,17 +17,16 @@ int main() } cout << endl; - //Given the int array arr, generate another int array output. - //whose element indiciates how many elements in arr is smaller than arr[i]. - //For example, if arr is given as [5,8,5,6,8,1,5,9,5,8], - //output should be [1,6,1,5,6,0,1,9,1,6]. - int* output = new int[arrsize]; cout << "Array output: "; - /*********************************** - Implement the code here! - ************************************/ + for (int i = 0; i < arrsize; i++) { + int num = 0; + for (int j = 0; j < arrsize; j++) { + if (arr[j] < arr[i]) num++; + } + output[i] = num; + } for (int i = 0; i < arrsize; i++) { cout << output[i] << " ";