|
|
@ -47,7 +47,7 @@ int multi_string(const char* str, int factor) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int multi_using_two_comp(int num2, int num3) { |
|
|
|
int multi_two_comp(int num2, int num3) { |
|
|
|
int result = 0; |
|
|
|
while (num2 != 0) { |
|
|
|
if (num2 & 1) { |
|
|
@ -63,7 +63,7 @@ int multi_by_even(int num, int factor) { |
|
|
|
return (num >> 1) << (factor + 1); |
|
|
|
} |
|
|
|
|
|
|
|
int multi_using_lookup_table(int num1, int num2) { |
|
|
|
int multi_lookup_table(int num1, int num2) { |
|
|
|
int lookup_table[10][10] = { |
|
|
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
|
|
|
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, |
|
|
@ -79,7 +79,7 @@ int multi_using_lookup_table(int num1, int num2) { |
|
|
|
return lookup_table[num1][num2]; |
|
|
|
} |
|
|
|
|
|
|
|
int multi_using_logical_op(int num1, int num2) { |
|
|
|
int multi_logical_op(int num1, int num2) { |
|
|
|
int result = 0; |
|
|
|
while (num2) { |
|
|
|
if (num2 & 1) { |
|
|
@ -99,7 +99,7 @@ int multi_by_prime(int num, int prime) { |
|
|
|
return num * (prime - 2) + num; |
|
|
|
} |
|
|
|
|
|
|
|
int multi_using_increment(int num1, int num2) { |
|
|
|
int multi_increment(int num1, int num2) { |
|
|
|
int result = 0; |
|
|
|
for (int i = 0; i < num2; ++i) { |
|
|
|
result += num1; |
|
|
@ -119,7 +119,7 @@ int multi_by_odd(int num, int factor) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
int multi_using_binary_enumeration(int num1, int num2) { |
|
|
|
int multi_binary_enumeration(int num1, int num2) { |
|
|
|
int result = 0; |
|
|
|
while (num1 && num2) { |
|
|
|
if (num2 & 1) { |
|
|
@ -131,7 +131,7 @@ int multi_using_binary_enumeration(int num1, int num2) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
int multi_using_differences(int num1, int num2) { |
|
|
|
int multi_differences(int num1, int num2) { |
|
|
|
int difference = (num1 > num2) ? num1 - num2 : num2 - num1; |
|
|
|
int sum = (num1 > num2) ? num1 + num2 : num2 + num1; |
|
|
|
return (sum - difference) * difference / 4; |
|
|
|