Skip to content

Instantly share code, notes, and snippets.

@abbas-oveissi
Created October 19, 2015 20:34
Show Gist options
  • Save abbas-oveissi/88963cb8cc7a52e5ced9 to your computer and use it in GitHub Desktop.
Save abbas-oveissi/88963cb8cc7a52e5ced9 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int a[10], b[10], c[20];
for (int i = 0; i < 10; i++)
a[i] = b[i] = 0;
for (int i = 0; i < 20; i++)
c[i] = 0;
a[9] = 4;
a[8] = 1;
b[9] = 4;
b[8] = 2;
b[7] = 3;
int counter = 10;
for (int i = 9; i > -1; i--)
{
for (int j = 9; j > -1; j--)
{
int mul = (a[i] * b[j]);
c[j + counter] = mul + c[j + counter];
if (c[j + counter] > 9)
{
c[j + counter - 1] += (c[j + counter] / 10);
c[j + counter] = c[j + counter] % 10;
}
}
counter--;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment