피자 나눠 먹기(1)
class Solution {
public int solution(int n) {
int answer = (n%7 == 0) ? n/7 : n/7 + 1;
return answer;
}
}
- 올림
Math.ceil(double a) // return type : double
- 내림
Math.floor(double a) // return type : double
- 반올림
Math.round(double a) // return type : long Math.round(float a) // return type : int
- 몫
Math.floorDiv(int x, int y) // return type : int Math.floorDiv(long x, long y) // return type : long
- 나머지
Math.floorMod(int x, int y) // return type : int Math.floorMod(long x, long y) // return type : long
- 절대값
Math.abs(double a) // return type : double Math.abs(float a) // return type : float Math.abs(int a) // return type : int Math.abs(long a) // return type : long
import math
def solution(n):
answer = math.ceil(n / 7)
return answer
올림(ceil)
import math print(math.ceil(3.14)) # 4
반올림(round)
print(round(3.14) # 3 # 사사오입 원칙(반올림 할 자리의 수가 5이면 반올림 할 때 앞 자리 숫자가 짝수면 내림, 홀수면 올림을 함) print(round(3.5)) # 4 print(round(4.5)) # 4
내림(floor)
import math print(math.floor(3.14)) # 3
버림(trunc)
import math print(math.floor(-1.23)) # -2 print(math.trunc(-1.23)) # -1, 0에 가까운 정수 선택
Javascript 기초
변수
let
자료형
// 문자 (홑,쌍따옴표 상관 없음)
let name = 'sparta';
let name = "camp";
let num = 10;
console.log(num + name); // 10sparta : 문자 + 숫자 하면 둘 모두를 문자로 묶음
// boolean
let age = 18;
let adult = age > 20;
console.log(adult); // false
// 리스트
let fruits = ['사과', '딸기', '수박'];
console.log(fruits[0]); // 사과
// 딕셔너리
let course = {
'name': '홍길동',
'age': 18
};
반복문
let fruits = ['사과', '딸기', '수박'];
for (let i = 0; i < fruits.length; i++) {
let fruit = fruits[i];
console.log(fruit);
}
조건문
let fruits = ['사과', '딸기', '수박'];
for (let i = 0; i < fruits.length; i++) {
let fruit = fruits[i];
console.log(fruit == '수박');
}
함수
function sample() {
alert('얼럿!');
}
백틱
let name = '내 이름';
let text = `${name}님의 스프링 5주 완주를 축하합니다!`;
console.log(text); // 내 이름님의 스프링 5주 완주를 축하합니다!
생성(Creational) 패턴
구조(Structural) 패턴
행위(Behavioral) 패턴
Annotation
빈(Bean) VS 컴포넌트(Component)
Spring MVC 기본 어노테이션