백준 2231번: 분해합
·
PS
문제자연수 N이 주어졌을 때, N의 가장 작은 생성자를 구해내는 프로그램을 작성하시오.    실행 결과   코드(c++)#include #include using namespace std;int main() { int n; cin >> n; int result = 0; for (int i = 1; i 0) { /* 자릿수별로 더하기 */ sum += temp % 10; temp /= 10; if (temp == 0) break; } if (sum == n) { /* 입력받은 n과 일치되면 for 문 종료 */ result = i; break; } } cout     코드 설명사용자로부터..
생활코딩 JavaScript 객체지향 프로그래밍 (2)
·
Web/JavaScript
객체 실제로 사용하기 console.log("Math.PI", Math.PI); console.log("Math.random()", Math.random()); console.log("Math.floor(3.9)", Math.floor(3.9)); // 객체에 소속된 함수 = 메소드 var MyMath = { PI: Math.PI, random: function(){ return Math.random(); }, floor: function(val) { return Math.floor(val); } } console.log(MyMath.PI); console.log(MyMath.random()); console.log(MyMath.floor(3.9)); "this" 란? 메소드 내에서 메소드가 속한 객체를..