분류 전체보기

Coding 수업정리/항해99

[JS]몫 구하기

function solution (num1, num2){ return Math.floor( num1 / num2 ) ; } function solution2 (num1, num2) { return parseInt( num1 / num2 ) ; } console.log(solution(7,-2)); // -3 console.log(solution2(7,-2)); // -4 몫을 구하는데는 parseInt와 Math.floor가 있다. 음수일 경우 Math.floor 값이 다르게 나오므로 주의. 두 메소드의 차이를 한번 더 알아볼 것.

Coding 수업정리/항해99

[항해99]JS 문법정리 - 3

[[[각종 ES6 문법 소개]]] let, const var와 다르게 재선언 불가. let : 재할당 가능 const: 재할당도 불가능 arrow function function, return, 괄호, 중괄호 생략 가능. // ES5 function func() { return true } //ES6 const func = () => true const func = () => { return true } () => {} parm => {} (parm1, parm2, ...parms) -> {} // 익명 화살표 함수 () => {} 삼항연산자 컨디션 ? 참이면 : 거짓이면 condition ? expr1 : expr2 console.log(true ? "참" : "거짓") // 참 console.log(..

Coding 수업정리/항해99

JS 문법정리 - 2

조건문 if문 기본적인 if 문 let x = 10; if (x > 0) { console.log("x는 양수입니다."); } if-else let x = -10; if (x > 0) { console.log("x는 양수입니다."); } else { console.log("x는 음수입니다."); } if-else else-if 조건을 순서대로 비교 let x = 0; if (x > 0) { console.log("x는 양수입니다."); } else if (x < 0) { console.log("x는 음수입니다."); } else { console.log("x는 0입니다."); } switch문 문자열 비교. default는 모두 안맞으면 실행되는 최종 코드 let fruit = "사과"; switch (..

Coding 수업정리/항해99

[항해99]JS 문법정리 - 1

JS 언어 특징 객체지향 프로그래밍 지원 JS 는 동적타이핑 : 데이터 타입은 런타임에 변수에 할당되는 값에 따라 결정됨. 선언 할때 타입을 지정하지 않음. 함수형 프로그래밍 지원 : 함수를 인자로 사용 가능 비동기 처리 클라이언트 측 및 서버측 모두에서 사용 가능 변수와 상수 변수 이름 : 저장된 값의 고유 이름 myVar 변수 값 : 변수에 저장된 값 "hello world" 변수 할당 : 변수에 값을 저장 = ''hello world'; 변수 선언 : 변수를 사용하기 위해 컴퓨터에게 알림 var myVar 변수 참조 : 변수에 할당된 값 읽어옴 example = myVar + myVar2 var myVar = ''hello world'; var : 같은 이름으로 다시 선언 가능 let : 같은 이름..

Computer Language/JavaScript

[JS]array.join();, toString();, map();, from();, slice();, reverse();,sort();

array.ptororype.join(); > Array.prototype.toString(); 원본 유지 결과 string 반환 join(separator?: string): string; join은 array로 새로운 string을 생성, 반환해준다. seperator: 생략 ,로 구분해서 출력 "string입력" ", " " and " 해당 값으로 구분자 적용 '' or "" 붙여서 출력 여기서 array란, index값이 0부터 시작해서 순차적으로 올라가는 일반적인 array를 말하며, index값에 다른 값(string등)이 추가된 경우 array-like object로 분류되어, join.call을 사용한다.(참고 https://developer.mozilla.org/en-US/docs/Web..

Computer Language/JavaScript

[JS]array.find();, filter();, some();, every();, reduce();, reduceRight();

array.prototype.find(); 원본 유지 해당 array 요소 한개 반환 해당 조건을 만족하는 모든 요소의 반환이 필요할 경우 filter(); 사용. find(callbackFn) find(callbackFn, thisArg) const result = students.find(function(value, index){ return value.score === 90; }); 아래와 같이 간략화 가능함. const result2 = students.find((value) => value.score=== 90); console.log(result); 여기서 콜백함수는 boolean 타입을 반환해야 한다. 이 경우 value.score가 true가 될 경우, 해당 값을 반환하고 바로 종료된다. ..

Computer Language/JavaScript

[JS]array.splice();

array.splice(); 원본 변경 지워진 값 array로 반환 splice는 array에서 원하는 부분을 지우고, 새로운 값을 넣어준다. splice(start, deleteCount?, item1?, item2?, itemN?) start : array.length 0 해당 갯수만큼 지움. item1, item2, itemN : 해당 아이템을 그 자리에 넣어줌. return : 지워진 값이 array로 반환됨. (1개든, 0개든 무조건 array로 반환됨)

Computer Language/JavaScript

[JS] 연산, 반복문

//1. String concatenation console.log('my' + 'cat'); //mycat console.log('1' + 2); //12 console.log(`string literals: 1+2 = ${1 + 2}`); //string literals: 1+2 = 3 //2. Numberic operators console.log(1 + 1); //add 더하기 console.log(1 - 1); //substract 빼기 console.log(1 / 1); //divide 나누기 console.log(1 * 1); //multiply 곱하기 console.log(5 % 2); //remainder 나머지 console.log(2 ** 3); //exponentiation 2의 3..

Computer Language/JavaScript

[JS] variables.js

// 1. Use strict // added in ES 5 선언 안된 변수의 할당을 막아줌. // use this for Vanila Javascript. 순수 바닐라 자바스크립트 작성시 되도록 써줄것. 'use strict'; // 2. Variable, rw(read/write) // let (added in ES6) 읽고 쓰기 가능 let globalName = 'global name'; { let name = 'ellie'; console.log(name); name = 'hello'; console.log(name); console.log(globalName); } console.log(name); console.log(globalName); // var (don't ever use this!..

Computer Language/JavaScript

[JS] script defer

parsing : 한줄씩 실행 fetching : 서버에서 받아옴 자바스크립트 에서는 너무 유연해서 ECMA5에서 추가됨. 선언안된 값 할당 안되게 막음. 'use strict' 출처 https://youtu.be/tJieVCgGzhs

Computer Language/java

[JAVA] Collections - ArrayList

import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static void main(String[] args) { List integerList = new ArrayList(); integerList.add(1); integerList.add(5); integerList.add(4); integerList.add(9); System.out.println(integerList); Collections.sort(integerList); //sort시켜줌 System.out.println(integerList); System.out.println(integerList.si..

카테고리 없음

[JAVA]LocalDate ...

보호되어 있는 글입니다.

Computer Language/java

[JAVA] exception

아래 예제에서는 throw로 다음 사람에게 에러메세지를 넘겨줘야 해당 부분 에러메세지가 출력되고, 그 뒷부분도 실행이 된다. 일단 기록을 위해 적어둔다. import java.io.IOException; class ArrayCalculation { int[] arr = { 0, 1, 2, 3, 4 }; public int divide(int denominatorIndex, int numeratorIndex) throws ArithmeticException, ArrayIndexOutOfBoundsException{ return arr[denominatorIndex] / arr[numeratorIndex]; } } public class Main { public static void main(String[]..

Coding 수업정리/항해99

[JAVA 문법]객체지향 퀴즈

원본 접은코드 더보기 abstract class Human { private int x, y; public String name; public int age = 10; public int speed = 1; public double totalTime = 0.0; boolean runnable; boolean swimmable; void walk(int x, int y) { printLocation(); double time = (float) (Math.abs(this.x + x) + Math.abs(this.y + y)) / (speed + 2); System.out.println(name + "이/가 뛰기 시작합니다."); this.x = x; this.y = y; System.out.println(n..

Computer Language/java

[JAVA] abstract class, interface

abstract class Bird { private int x, y, z; void fly(int x, int y, int z) { printLocationBefore(); System.out.println("이동합니당."); this.x = x; this.y = y; if (flyable(z)) { this.z = z; } else { System.out.println("그높이 안됨"); } printLocation(); } abstract boolean flyable(int z); public void printLocation() { System.out.println("현위치 : (" + x + "," + y + "," + z + ")"); System.out.println("======이동완료==..

Computer Language/언어 - 분류중

[Python] csv 첫번째 key 인식 못하는 문제 해결법

이런 상황에서, 읽어올때 보통은 잘 읽어지는데 종종 아래와 같은 에러가 나올때가 있다. 원인을 알아보기 위해 전체 배열을 출력해보면, ?? Title앞에 \ufeff 라는 이상한 글자가 붙어있다. 해결방법 1. (권장) 인코딩 문제인데, open 부분에 아래와 같이 encoding='utf-8-sig' 를 넣어주면 잘 인식한다. import csv books = [] # Add books to your shelf by reading from books.csv with open("books.csv", encoding='utf-8-sig') as file: file_reader = csv.DictReader(file) for book in file_reader: books.append(book) # Prin..

카테고리 없음

CS50-04-filter-less

https://cs50.harvard.edu/x/2023/psets/4/filter/less/#specification Filter - CS50x 2023 Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. cs50.harvard.edu 코드가 지나치게 길어져서 블러 부분을 다시 만들어야한다. 작동은 정상작동 함. #include "helpers.h" #include #include // Convert image to grayscale void grayscale(int height, int width, RGBTRIPLE image[height][width..

Coding 수업정리/CS50

[컴파일러]makefile 에 대하여

https://kthdev.tistory.com/40 (작성중) smily project 를 작성하고 컴파일까지 완료, 정상작동 확인을 했고 제출까지 했다. [chat gpt는 제출하는 과제에는 사용하지 않았습니다.] 아무리 찾아봐도 나는 분명 helpers.c를 수정했는데, 실행은 colorize를 했다. colorize는 helpers.h를 가지고 있지만 helpers.c는 언급하지 않고, helpers.c는 makefile이라는 파일에서 언급이 되어있었다. makefile이라는게 뭔지 처음봐서, chat gpt에게 함 물어봤다. 파일을 올릴수가 없어서, 내용을 구분해서 다 알려주고 질문했다. 내용이 너무 길어서 질문을 접어둔다. 더보기 ## content of makefile ## colorize:..

Coding 수업정리/CS50

CS50-04-smiley [ 작성중 ]

https://cs50.harvard.edu/x/2023/labs/4/smiley/ https://kthdev.tistory.com/41 [컴파일러]makefile 에 대하여 https://kthdev.tistory.com/40 (작성중) smily project 를 작성하고 컴파일까지 완료, 정상작동 확인을 했고 제출까지 했다. [chat gpt는 제출하는 과제에는 사용하지 않았습니다.] 아무리 찾아봐도 나는 분명 h kthdev.tistory.com Lab 4: Smiley - CS50x 2023 Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. c..

Computer Language/C

[C] strcasecmp, tolower, toupper

strcasecmp는 C 언어의 문자열 비교 함수로, 대소문자를 구분하지 않고 두 문자열을 비교합니다. 이 함수는 두 문자열이 같으면 0을 반환하고, 첫 번째 문자열이 사전 순으로 두 번째 문자열보다 앞서면 음수를 반환하고, 첫 번째 문자열이 사전 순으로 두 번째 문자열보다 뒤에 있으면 양수를 반환합니다.strcasecmp 함수는 헤더 파일에 정의되어 있으며, 다음과 같이 사용할 수 있습니다.cCopy code#include int result = strcasecmp(const char *s1, const char *s2); 여기서 s1과 s2는 비교할 두 문자열입니다.예를 들어, 두 문자열 "Hello"와 "hello"를 비교하는 경우 다음과 같이 사용할 수 있습니다.cCopy code#include ..

Coding 수업정리/CS50

CS50-03-snackbar (chat gpt 분석)

https://cs50.harvard.edu/x/2023/problems/3/snackbar/ Snackbar - CS50x 2023 Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. cs50.harvard.edu 대답, 코드부분은 +더보기를 누르시면 나옵니다! 아래는 내가 작성한, 오류가 나는 코드이다. 더보기 // Practice using structs // Practice writing a linear search function /** * Beach Burger Shack has the following 10 items on their menu..

Coding 수업정리/CS50

CS50-04-license chat gpt 질문으로 이해하는 동적할당과 해제

글이 너무 길어져서, 대답 부분과 코드 부분을 접어두었습니다. 접힌 부분 누르면 내용이 나옵니다. License - CS50x 2023 Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. cs50.harvard.edu 이 부분이 너무 이해가 안가는데, 어디서부터 검색을 해야할지 막막했다. 마침 chat gpt가 생각나서 컴공과 친구가 옆에 앉아있다고 생각하고 질문을 해보기로 했다. 연습문제와 개념 부분만 chat gpt에게 물어보고, 제출하는 과제에는 절대 사용하지 않을 예정이다. 우선 아래와 같이 코드를 짜줬는데, 이해가 안가는 부분을 여러 단계에 걸쳐..

Coding 수업정리/CS50

CS50-04-problems - bottomup

https://cs50.harvard.edu/x/2023/problems/4/bottomup/ Bottom Up - CS50x 2023 Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. cs50.harvard.edu 외부 파일을 다루는 과정으로 처음 들어가는 연습문제로, 코드 4줄만 추가하면 되는 간단한 문제이다. Bottomup.c // Copies a BMP file #include #include #include "bmp.h" int main(int argc, char *argv[]) { // Ensure proper usage if (argc !..

Computer Language/C

[C]동적할당 Dynamic Memory Allocation

C언어의 메모리 동적 할당 malloc으로 할당 할당후 반드시 free로 반환해야 한다. 항상 모든 자원을 활용하지 않아도 되는 카페의 회원등은 동적할당을 하여 해당 맴버의 메모리를 필요한만큼만 할당하여 사용함.

Computer Language/C

[C]void pointer

모든 포인터는 4byte의 크기를 가지므로, void포인터라는 형태가 없는 포인터도 사용이 가능하다. void pointer는 여러가지 자료형에 상관없이 저장이 가능하나, 컴퓨터가 그 자료를 읽어오기 위해서 필요한 데이터의 크기값(int 4byte, char 1byte ...)이 없어서 호출시 해당 자료형을 알려주어야 호출이 가능하다. *(char*)p = 형식으로 표기한다. 호출시 자료형을 지정하지 않으면 불러울 수 없다.

kthdev
'분류 전체보기' 카테고리의 글 목록 (7 Page)