No Programming section!!!?

DJ's Place
Post Reply
User avatar
[DXA]avatar
Principality/2C
Principality/2C
Posts: 180
Joined: 13 Apr 2009, 20:38

No Programming section!!!?

Post by [DXA]avatar »

so ye i need some help in a programming thingy

well i was supposed to make a c++ program which takes 2 matrices and multiples them(cross product thingy) to form a matrix 3 with those values.
so basically my program works for 2x2 - 3x3 ... but fails at high numbers for some unknown reason O.O ....
i've already submitted it so hopefully the professor only tries a 2x2 xD ... but still i wanna know where my mistake was !

Code: Select all

#include<iostream>
#include<string>
using namespace std;
int const max_rows=100;
int const max_columns=100;

void crossproduct(int array1[][max_columns],int array2[][max_columns],int array3[][max_columns], int row, int column);
void main()
{

int matrix1[max_rows][max_columns];
int matrix2[max_rows][max_columns];
int matrix3[max_rows][max_columns];
int row1;
int row2;
int row3;
int column1;
int column2;
int column3;
do
{
cout << "please enter the number of rows for matrix 1" << endl;
cin >> row1;
if(row1 >=100)
   cout << "please enter a number less than 100" << endl;
}while(row1>=100);

do
{
cout << "please enter the number of columns for matrix 1" << endl;
cin >> column1;
if(column1 >=100)
   cout << "please enter a number less than 100" << endl;
}while(column1>=100);

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

for(int j=0; j<column1; j++)
{

cout << "please enter the value of matrix1 [" << i+1 << "] [" << j+1 << "]" <<endl;
cin >> matrix1[i][j];

}

}

cout << "the number of rows for matrix 2 will equal the number of columns in matrix 1" << endl;
row2=column1;
do
{
cout << "please enter the number of columns for matrix 2" << endl;
cin >> column2;
if(column2 >= 100)
cout << "please enter a number less than 100" << endl;
}while(column2>=100);

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

for(int j=0; j<column2; j++)
{

cout << "please enter the values of matrix2 [" << i+1 << "] [" << j+1 << "]" <<endl;
cin >> matrix2[i][j];

}

}

row3 = row1;

column3 = column2;

crossproduct(matrix1,matrix2,matrix3,row3,column3);

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

for(int j=0; j<column3; j++)
{

cout << " the cross product matrix has the values [" << i+1 << "][" << j+1 << "] = " << matrix3[i][j] << endl ;
}

}

system ("pause");
}

void crossproduct(int array1[][max_columns],int array2[][max_columns],int array3[][max_columns], int row, int column)
{
int product;
int total=0;
for(int i=0; i< row; i++)
{
for(int j=0; j<column;j++)
{
for(int h=0; h<column;h++)
{
product = array1[i][h] * array2[h][i];
total = total+ product;

}
array3[i][j] =total;
total=0;
}
}
}
avatar, I'm gonna HUNT you down with my FGS-Sentinels! :P
~][FGS][Nobody~
User avatar
Majster
Virtue/4E
Virtue/4E
Posts: 463
Joined: 30 Sep 2010, 20:20
Location: Poland

Re: No Programming section!!!?

Post by Majster »

btw. where is new version of your map Multi? I liked this map. Give it to Chinny right now! :-D
ShadowRunner wrote: There's paranoia and anger everywhere about fps, people are taking 0a FAR too seriously, liven the game up and make it more fun for EVERYONE. (and me and Chees lol)
User avatar
[DXA]avatar
Principality/2C
Principality/2C
Posts: 180
Joined: 13 Apr 2009, 20:38

Re: No Programming section!!!?

Post by [DXA]avatar »

emmmmmm i've been busy man :P ........... soo like i havn't touched it yet O.O!!!
but i saw u made some extremely good changes to your map :D!
avatar, I'm gonna HUNT you down with my FGS-Sentinels! :P
~][FGS][Nobody~
Post Reply