목록분류 전체보기 (57)
독도갈매기의 개발 블로그
#include using namespace std; int main() { int a = 0, b = 0; cin >> a; cin >> b; // 참고로 이런식으로 세미콜론만 잘 붙여준다면 한줄로 정렬할 수 있습니다. cout
#include using namespace std; long fibo(long a) { // 피보나치나 팩토리얼은 입력값에 따라 결과 값이 기하급수적이기 때문에 long타입으로 함수를 지정합니다. // 멈추는 조건을 정함 if (a > a; cout
#include using namespace std; long fac(long a) { if (a > a; cout
#include using namespace std; int main() { char input; cin >> input; cout
용어정리 Class 객체의 특성을 정의 Object Class의 인스턴스 Constructor 인스턴화 되는 시점에서 호출되는 메서드 Merhod 객체의 능력 Ex) 걷기, 짖기, 달리기 위 내용은 Mozilla에서 정의한 용어입니다. Class생성 간단한 설명 class Person { // 클래스 정의 constructor(name, age) { // 생성자 함수 생성 (Constructor) this.name = name; // 클래스 field 구성 this.age = age; // 클래스 field 구성 } say() { // 클래스 Method 생성 if (this.name) { console.log(`안녕 나는 ${this.name}이야`); } else { console.log(`안녕하세요..
#include using namespace std; int main() { int count, max; int* arr = new int[9]; for (int i = 0; i > arr[i]; } max = arr[0]; count = 0; for (int i = 0; i arr[i]) { max = max; } else if (max < arr[i]) { max = arr[i]; count = i + 1; } else count = i + 1; } cout
spread와 rest는 어느곳에 쓰이는가? spread : 객체나 배열의 내부나 함수를 호출해주는 인자에서 사용합니다. rest : (destructuring으로 통해 값을 받아오는) 객체나 배열의 받아오는 변수나 (값을 받아오는) 함수 파라미터에서 주로 쓰입니다. Spread let Hong = { name : "홍길동", job : "도적", age : "29" } let Kim = { name : "김영희", job : "보험사 직원", age : "29" } let Hong2 = { father : {...Hong}, // Hong 객체의 속성들을 한줄로 모두 받아옴 mother : {...Kim}, // Kim 객체의 속성들을 한줄로 모두 받아옴 name : "홍철수", age : "6" } ..
#include using namespace std; int main() { int input, min, max; cin >> input; int* arr = new int[input]; for (int i = 0; i > arr[i]; } max = arr[0]; min = arr[0]; for (int i = 0; i arr[i]) ? max : arr[i]; } for (int i = 0; i arr[i]) ? arr[i] : min; } cout
구조분해할당이란 무엇일까? 배열의 인덱스 혹은 객체의 키를 기준으로 원하는 값만 빼내는 것을 구조분해할당이라고 합니다. 어떻게 사용할까? let Person = { firstname : "홍", lastname : "길동", age : 18, role : "학생", family : { mom : "김영희", father : "홍철수" } }위 같은 객체가 있고 필요한 값이 firstname, father이라면 저희는 이런 식으로 코드를 짤 수 있을것입니다. let firstname = Person.firstname; let father = Person.family.father console.log(firstname, father); // 홍 홍철수하지만 오늘 이 포스팅을 읽는다면 이 2줄의 코드를 한줄로..
이 포스팅은 이어지는 포스팅입니다. 전편을 먼저 읽고 오시는 것을 권장드립니다. Prototype Object 먼저 저번 코드를 가져오면 let Person = () => {} let kim = new Person()저희는 Person이라는 함수를 만들었고 이때 일어나는 일을 그림을 나타낸다면 ↓ 위 그림처럼 저희는 Person이라는 함수를 하나 정의했지만 실제 JS에서는 function Person() {}하나와 Person Prototype Obejct하나 총 두개가 만들어지죠 그걸로 끝나는 것이 아닌 Person의 property인 prototype은 Person Prototype Obejct의 constructor를 가르킵니다. 그와 반대로 Person Prototpye의 property인 con..