|
@ -10,9 +10,9 @@ int getIntInput(const char *message); |
|
|
double factorial(double num); |
|
|
double factorial(double num); |
|
|
double permutation(int n, int r); |
|
|
double permutation(int n, int r); |
|
|
double combination(int n, int r); |
|
|
double combination(int n, int r); |
|
|
double pow(double num1, int num2); |
|
|
|
|
|
|
|
|
double pow(double num1, double num2); |
|
|
|
|
|
|
|
|
int main() { |
|
|
|
|
|
|
|
|
int calculator() { |
|
|
int choice; |
|
|
int choice; |
|
|
double num1, num2, result; |
|
|
double num1, num2, result; |
|
|
|
|
|
|
|
@ -85,29 +85,29 @@ double pow(double num1, int num2); |
|
|
case 5: |
|
|
case 5: |
|
|
return pow(num1, num2); |
|
|
return pow(num1, num2); |
|
|
case 6: |
|
|
case 6: |
|
|
return fmod(num1, num2); |
|
|
|
|
|
|
|
|
return 0;// fmod(num1, num2); |
|
|
case 7: |
|
|
case 7: |
|
|
return log(num1); |
|
|
|
|
|
|
|
|
return 0;// log(num1); |
|
|
case 8: |
|
|
case 8: |
|
|
return pow(num1, num2); |
|
|
return pow(num1, num2); |
|
|
case 9: |
|
|
case 9: |
|
|
return sqrt(num1); |
|
|
|
|
|
|
|
|
return 0;// sqrt(num1); |
|
|
case 10: |
|
|
case 10: |
|
|
return num1 * num1; |
|
|
return num1 * num1; |
|
|
case 11: |
|
|
case 11: |
|
|
return num1 * num1 * num1; |
|
|
return num1 * num1 * num1; |
|
|
case 12: |
|
|
case 12: |
|
|
return cbrt(num1); |
|
|
|
|
|
|
|
|
return 0;// cbrt(num1); |
|
|
case 13: |
|
|
case 13: |
|
|
return factorial(num1); |
|
|
return factorial(num1); |
|
|
case 14: |
|
|
case 14: |
|
|
return pow(num1, num2); |
|
|
return pow(num1, num2); |
|
|
case 15: |
|
|
case 15: |
|
|
return sin(num1 * M_PI / 180.0); |
|
|
|
|
|
|
|
|
return 0;// sin(num1 * M_PI / 180.0); |
|
|
case 16: |
|
|
case 16: |
|
|
return cos(num1 * M_PI / 180.0); |
|
|
|
|
|
|
|
|
return 0;// cos(num1 * M_PI / 180.0); |
|
|
case 17: |
|
|
case 17: |
|
|
return tan(num1 * M_PI / 180.0); |
|
|
|
|
|
|
|
|
return 0;// tan(num1 * M_PI / 180.0); |
|
|
|
|
|
|
|
|
case 18: |
|
|
case 18: |
|
|
return permutation((int)num1, (int)num2); |
|
|
return permutation((int)num1, (int)num2); |
|
@ -149,10 +149,10 @@ int getIntInput(const char *message) { |
|
|
return input; |
|
|
return input; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
double pow(double num1, int num2){ |
|
|
|
|
|
|
|
|
double pow(double num1, double num2){ |
|
|
double product = 1; |
|
|
double product = 1; |
|
|
for(int i = 0; i < num2; ){ |
|
|
|
|
|
|
|
|
for(int i = 0; i < num2; i++){ |
|
|
product *= num1; |
|
|
product *= num1; |
|
|
} |
|
|
} |
|
|
return product; |
|
|
return product; |
|
|
} |
|
|
|
|
|
|
|
|
} |