코딩 1막 <C++개념편>/코딩 1막 <C++응용편>(34)
-
[C++] Factorial 만들기
#include using namespace std; //1! = 1 //2! = 2*1! //3! = 3*2! //4! = 4*3! //n! = n*(n-1)! //재귀 함수 : 자기 자신을 호출하는 함수 int Factorial(int num) { if (num == 1) { return 1; } return num * Factorial(num - 1); } void main() { cout
2022.05.31 -
[C++] 함수오버로딩을 써서 계산기 함수를 만들어 보자
#include using namespace std; float Sum(float inputA, float inputB) { return inputA + inputB; } float Sub(float inputA, float inputB) { return inputA - inputB; } float Div(float inputA, float inputB) { if (inputB == 0) { cout
2022.05.31 -
[C++] 다중for문을 써서 별을 찍어보자
#include using namespace std; void main() { cout
2022.05.31 -
[C++] 조건문을 써서 데미지 공식을 만들어보자
#include using namespace std; void main() { float damage = 16; int atk = 5; int def = 5; int dex = 5; int spd = 2; int mag = 2; int res = 4; float resultDamage; resultDamage = damage + (atk + def + dex) * 2 - (spd + mag + res) / 2; if (resultDamage > 40) { cout
2022.05.30