Name: how do? 2011-02-05 13:59
int A[3] = {5,5,1};
int B[3] = {3,2,0};
int C[4] = {0,0,0,0};
int F[7] = {0,0,0,0,0,0,0};
//Set up nested loops:
for(int i = 0; i < 3; ++i)
{
for(int k = 0; k < 3; ++k)
C[k] = 0;
for(int j = 0; j < 3; ++j)
{
//Multiply elements of A * B = C:
C[j] += A[i] * B[j];
//Deal with Carry of multiplication:
if(C[j] > 9)
{
C[j+1] += CarryTheOne( C[j] );
//F[j+1] += C[j+1];
}
//Add to contiguous answer:
F[j+i] += C[j];
//Deal with Carry of addition:
F[j+i+1] += CarryTheOne( F[j+i] );
}
cout << "\n\tC = ";
for(int k = 0; k < 3; ++k)
cout << C[k];
cout << endl;
}
int B[3] = {3,2,0};
int C[4] = {0,0,0,0};
int F[7] = {0,0,0,0,0,0,0};
//Set up nested loops:
for(int i = 0; i < 3; ++i)
{
for(int k = 0; k < 3; ++k)
C[k] = 0;
for(int j = 0; j < 3; ++j)
{
//Multiply elements of A * B = C:
C[j] += A[i] * B[j];
//Deal with Carry of multiplication:
if(C[j] > 9)
{
C[j+1] += CarryTheOne( C[j] );
//F[j+1] += C[j+1];
}
//Add to contiguous answer:
F[j+i] += C[j];
//Deal with Carry of addition:
F[j+i+1] += CarryTheOne( F[j+i] );
}
cout << "\n\tC = ";
for(int k = 0; k < 3; ++k)
cout << C[k];
cout << endl;
}