λ°μ νμ΄λμ§ μμ μλ λ°μ μ£½λλ€.
" He not busy being born is busy dying. "
- λ°₯ λλ°
μ§κΈ ν μΌμ κ³μ λ―Έλ£¨λ€ λ³΄λ©΄,
μΈμμ μ±κ³΅μΌλ‘ κ°λ κΈΈλ μ μ λ©μ΄μ§λ€.
μμ)
#include <iostream>
// λ μλ₯Ό λνλ ν¨μ
int add(int a, int b)
{
return a + b;
}
// λ μλ₯Ό κ³±νλ ν¨μ
int multiply(int a, int b)
{
return a * b;
}
int main()
{
// λ§μ
ν¨μ νΈμΆ
int sum = add(num1, num2);
std::cout << "λ μμ ν©: " << sum << std::endl;
// κ³±μ
ν¨μ νΈμΆ
int product = multiply(num1, num2);
std::cout << "λ μμ κ³±: " << product << std::endl;
return 0;
}
"λ
λ¦½μ± :"
κ° ν¨μ λλ λͺ¨λμ νΉμ μμ
μ μννκΈ° μν΄ μ€κ³λμμΌλ©°,
λ€λ₯Έ λͺ¨λκ³Ό λ
립μ μΌλ‘ μλν¨
"μ¬μ¬μ©μ± :"
ν¨μ λͺ¨λνλ μ½λμ μ¬μ¬μ©μ μ΄μ§ν¨ λμΌν κΈ°λ₯μ΄ μ¬λ¬ κ³³μμ νμν κ²½μ°
ν΄λΉ ν¨μ λλ λͺ¨λμ μ¬λ¬ κ³³μμ νΈμΆνμ¬ μ€λ³΅ μ½λλ₯Ό νΌν¨
"λλ²κΉ
λ° ν
μ€νΈ μ©μ΄μ± :"
μμ λͺ¨λ λ¨μλ‘ μ½λλ₯Ό λΆν νλ©΄ κ° λͺ¨λμ λ μ½κ²
λλ²κ·Ένκ³ ν
μ€νΈν μ μμΌλ©° λ²κ·Έλ₯Ό μ°Ύμλ΄κ³ μμ νκΈ°κ° λ μ©μ΄ν¨
"μ μ§ λ³΄μ μ©μ΄μ± :"
μ½λ λ³κ²½μ΄ νμν κ²½μ°, κ΄λ ¨ λͺ¨λλ§ μμ νλ©΄ λλ―λ‘
μ μ§ λ³΄μκ° κ°λ¨ν΄μ§λ©° λ€λ₯Έ λΆλΆμ μν₯μ λ―ΈμΉμ§ μκ³ λ³κ²½ κ°λ₯ν¨
n = n * (n - 1) * (n - 2) * γγγ * 1
// Factorial λͺ¨λν
int Factorial(int iCount)
{
int iValue = 1;
for (int j = 1; j < iCount; ++j)
{
iValue *= (j + 1);
}
return iValue;
}
int main()
{
int iValue = Factorial(5);
return 0;
}
// Factorial λͺ¨λν
int Factorial(int iCount)
{
int iValue = 1;
int j = 1;
while (j < iCount)
{
iValue *= (j + 1);
j += 1;
}
return iValue;
}
int main()
{
int iValue = Factorial(5);
return 0;
}
0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, 2 + 3 = 5, 3 + 5 = 8, 5 + 8 = 13
γγγ
// Pibonacci λͺ¨λν
int Fibonacci(int pNum)
{
int num1 = 1;
int num2 = 1;
int iValue = 0;
if (pNum == 1 || pNum == 2)
{
return 1;
}
else
{
for (int i = 0; i < pNum - 2; ++i)
{
iValue = num1 + num2;
num1 = num2;
num2 = iValue;
}
return iValue;
int main()
{
iValue = Fibonacci(10);
return 0;
}
// Pibonacci λͺ¨λν
int Fibonacci(int pNum)
{
int num1 = 1;
int num2 = 1;
int iValue = 0;
int i = 1;
if (pNum == 1 || pNum == 2)
{
return 1;
}
else
{
while (i < pNum - 2)
{
iValue = num1 + num2;
num1 = num2;
num2 = iValue;
}
}
return iValue;
int main()
{
iValue = Fibonacci(5);
return 0;
}
보μλ λΆμ΄ λ§μ§λ μκ² μ§λ§ νΉμ μλͺ»λ μ λ³΄κ° μμΌλ©΄ μλ €μ£Όμλ©΄ κ°μ¬νκ² μ΅λλ€