Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int power(int a, int n) {
- int number = 1;
- while (n) {
- if (n & 1) {
- number *= a;
- n--;
- }
- else {
- a *= a;
- n >>= 1;
- }
- }
- return number;
- }
- int number(int *array, int size) {
- int length = size / sizeof(array[0]);
- int sum = array[0];
- for (int i = 1; i != length; i++)
- sum += array[i] * power(10, i);
- return sum;
- }
- int mul(int *a, int *b, int size_a, int size_b) {
- return number(a, size_a) * number(b, size_b);
- }
- int main() {
- int a[3] = {1, 2, 3};
- int b[3] = {4, 5, 6};
- cout << mul(a, b, sizeof(a), sizeof(b)) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement