Resolve typo errors

This commit is contained in:
Mann Mehta 2020-04-04 18:16:40 +05:30
parent a82e679f2e
commit 8219e124a7

View File

@ -31,7 +31,7 @@ int binExpo(int a, int b) {
/// Iterative function to calculate exponent in O(log(n)) using binary exponent. /// Iterative function to calculate exponent in O(log(n)) using binary exponent.
int binExpo_alt(int a, int b) { int binExpo_alt(int a, int b) {
int res = 1; int res = 1;
while (b>0) { while (b > 0) {
if (b%2) { if (b%2) {
res = res*a; res = res*a;
} }
@ -45,9 +45,9 @@ int main() {
int a, b; int a, b;
/// Give two numbers a, b /// Give two numbers a, b
std::cin >> a >> b; std::cin >> a >> b;
if (a==0 && b==0) { if (a == 0 && b == 0) {
std::cout << "Math error" << std::endl; std::cout << "Math error" << std::endl;
} else if (b<0) { } else if (b < 0) {
std::cout << "Exponent must be positive !!" << std::endl; std::cout << "Exponent must be positive !!" << std::endl;
} else { } else {
int resRecurse = binExpo(a, b); int resRecurse = binExpo(a, b);