Joined

·
1,201 Posts

website and click on the two files at the very bottom of the page. (oh and check out the really crappy flash animation on that page... it's a first attempt so take it easy... click on the arrow.) Both of these run and do exactly what they're supposed to but I don't know how dirty my coding is after not haveing done any for about a year.

thanx to anybody who can help,

Gene Crumpler

1992 Stealth ES

Here's the code:

//code for converting a base 16 number to a base 10 number

// Gene Crumpler Nov. 2001

#include <iostream.h>

int power(int, int);

void main(){

bool out=true;

int total=0;

char hexa[100];

int deci[100];

cout << "Please input a hexadecimal number using any number keys and capitol letters only. ";

cin >> hexa;

int i = 0;

while (hexa

*){*

switch (hexa

switch (hexa

*){*

case '0':

decicase '0':

deci

*=0;break;*

case '1':

decicase '1':

deci

*=1;break;*

case '2':

decicase '2':

deci

*=2;break;*

case '3':

decicase '3':

deci

*=3;break;*

case '4':

decicase '4':

deci

*=4;break;*

case '5':

decicase '5':

deci

*=5;break;*

case '6':

decicase '6':

deci

*=6;break;*

case '7':

decicase '7':

deci

*=7;break;*

case '8':

decicase '8':

deci

*=8;break;*

case '9':

decicase '9':

deci

*=9;break;*

case 'A':

decicase 'A':

deci

*=10;break;*

case 'B':

decicase 'B':

deci

*=11;break;*

case 'C':

decicase 'C':

deci

*=12;break;*

case 'D':

decicase 'D':

deci

*=13;break;*

case 'E':

decicase 'E':

deci

*=14;break;*

case 'F':

decicase 'F':

deci

*=15;break;*

default:

cout << "This is not a base 16 number.";out=false;break;

}

i++;

}

if (out==false)

return;

i--;

int j=i;

for (int k=0;k<=i;k++){

total = total + (deci[k] * power(16,j));

j--;

}

cout << '\n' << "This number is "<< total << " in decimal notation.";

}

int power (int base, int exponent){

if (exponent == 0)

return 1;

if (exponent == 1)

return base;

else

return base * power(base, exponent - 1);

}

//code for inputing two matrices and calculating there product

// Gene Crumpler Nov. 2001

#include <iostream.h>

void main(){

int rows1, colms1, rows2, colms2;

cout << "Please input the number of rows and columns for matrix 1 and press enter after each number. ";

cin >> rows1 >> colms1;

cout << "Please input the number of rows and columns for matrix 2 and press enter after each number. ";

cin >> rows2 >> colms2;

int matrix1[20][20];

int matrix2[20][20];

int matrix3[20][20];

if (colms1 == rows2){

cout << "Input matrix 1 row by row, digit by digit press enter after each digit.";

for(int i=0;i<rows1;i++)

for (int j=0;j<colms1;j++)

cin >> matrix1default:

cout << "This is not a base 16 number.";out=false;break;

}

i++;

}

if (out==false)

return;

i--;

int j=i;

for (int k=0;k<=i;k++){

total = total + (deci[k] * power(16,j));

j--;

}

cout << '\n' << "This number is "<< total << " in decimal notation.";

}

int power (int base, int exponent){

if (exponent == 0)

return 1;

if (exponent == 1)

return base;

else

return base * power(base, exponent - 1);

}

//code for inputing two matrices and calculating there product

// Gene Crumpler Nov. 2001

#include <iostream.h>

void main(){

int rows1, colms1, rows2, colms2;

cout << "Please input the number of rows and columns for matrix 1 and press enter after each number. ";

cin >> rows1 >> colms1;

cout << "Please input the number of rows and columns for matrix 2 and press enter after each number. ";

cin >> rows2 >> colms2;

int matrix1[20][20];

int matrix2[20][20];

int matrix3[20][20];

if (colms1 == rows2){

cout << "Input matrix 1 row by row, digit by digit press enter after each digit.";

for(int i=0;i<rows1;i++)

for (int j=0;j<colms1;j++)

cin >> matrix1

*[j];*

cout <<"Input matrix 2 row by row, digit by digit press enter after each digit.";

for(int i=0;i<rows2;i++)

for (int j=0;j<colms2;j++)

cin >> matrix2cout <<"Input matrix 2 row by row, digit by digit press enter after each digit.";

for(int i=0;i<rows2;i++)

for (int j=0;j<colms2;j++)

cin >> matrix2

*[j];*

for (int i=0;i<rows1;i++)

for (int j=0;j<colms2;j++)

for (int k=0;k<colms1;k++){

matrix3for (int i=0;i<rows1;i++)

for (int j=0;j<colms2;j++)

for (int k=0;k<colms1;k++){

matrix3

*[j] += matrix1**[k] * matrix2[k][j];*

}

cout << "The product of these two matrices is: ";

for (int i=0;i<rows1;i++){

cout << '\n';

for(int j=0;j<colms2;j++)

cout << matrix3}

cout << "The product of these two matrices is: ";

for (int i=0;i<rows1;i++){

cout << '\n';

for(int j=0;j<colms2;j++)

cout << matrix3

*[j] << " ";*

}

}

else

cout << "These two matrices cannot be multiplied.";

}}

}

else

cout << "These two matrices cannot be multiplied.";

}