G
giambi
im trying to finish a program, but been having some dificulties in passing
a bidimensional array at a function...(til now nobody could help me) final
result should be a program that adds, subtracts and multiply two arrays,
but havent been able to do the rest once that this is right in the basis
of the program... this is what have done so far (sorry for the bad "Eng"
im trying but im portuguese so people say i sound like "Borat")!
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <fstream.h>
#include <ctype.h>
using namespace std;
//mxa
int L1;
int C1;
//mxb
int L2;
int C2;
void menu ();
void mxa ();
void mxb ();
void calc ();
void mxa (){
// A
cout<< "Matrix A" << endl;
cout<< "Lines:" << endl;
cin >>L1;
cout<< "Colums:" << endl;
cin>> C1;
int mx1 [L1][C1];
cout<<endl;
for (int m=0; m<L1; m++){
for (int n=0; n<C1; n++){
cout<< " Matrix element " << m+1 << " , " << n+1 <<endl;
cin>> mx1 [m][n];
cout<< endl;}}
for (int m=0; m<L1; m++){
for (int n=0; n<C1; n++){
cout<< mx1 [m][n]; }
cout<<endl;}
calc (mx1)
mxb();
}//Eo A
void mxb (){
//B
cout<< "Matrix B" << endl;
cout<< "Lines:" << endl;
cin>> L2;
cout<< "Colums :" << endl;
cin>> C2;
int mx2 [L2][C2];
cout<<endl;
for (int m=0; m<L2; m++){
for (int n=0; n<C2; n++){
cout<< "Matrix element " << m+1 << " , " << n+1 <<endl;
cin>> mx2 [m][n];
cout<< endl;}}
for (int m=0; m<L2; m++){
for (int n=0; n<C2; n++){
cout<< mx2 [m][n]; }
cout<<endl;}
calc (mx2);
}//Eo B
void calc (int a[][C1], int b[][C2]){ // <-------------------
/*
Here is the tricky part, for what i've seen and read i believe
that this should be right but unfortunately it just doesnt work
//using Dev-C++ 4.9.9.0>
*/
system("cls");
}//Eo calc
void menu (){
int opt;
cout<< "Main menu:" << endl;
cout<< "1 - Mx A" << endl;
cout<< "2 - Mx B" << endl;
cout<< "3 - Calc "<< endl;
cin>> opt;
if (opcao == 1) {mxa();}
else if (opcao ==2) {mxb ();}
else if (opcao == 3) { calc ();}
}//Eo Mmenu
int main(){
system("cls");
cout<< "Mx Calc 0.9 RC"<< endl;
cout<< "****************"<< endl;
cout<< endl;
menu ();
system("PAUSE");
return 0;
}
a bidimensional array at a function...(til now nobody could help me) final
result should be a program that adds, subtracts and multiply two arrays,
but havent been able to do the rest once that this is right in the basis
of the program... this is what have done so far (sorry for the bad "Eng"
im trying but im portuguese so people say i sound like "Borat")!
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <fstream.h>
#include <ctype.h>
using namespace std;
//mxa
int L1;
int C1;
//mxb
int L2;
int C2;
void menu ();
void mxa ();
void mxb ();
void calc ();
void mxa (){
// A
cout<< "Matrix A" << endl;
cout<< "Lines:" << endl;
cin >>L1;
cout<< "Colums:" << endl;
cin>> C1;
int mx1 [L1][C1];
cout<<endl;
for (int m=0; m<L1; m++){
for (int n=0; n<C1; n++){
cout<< " Matrix element " << m+1 << " , " << n+1 <<endl;
cin>> mx1 [m][n];
cout<< endl;}}
for (int m=0; m<L1; m++){
for (int n=0; n<C1; n++){
cout<< mx1 [m][n]; }
cout<<endl;}
calc (mx1)
mxb();
}//Eo A
void mxb (){
//B
cout<< "Matrix B" << endl;
cout<< "Lines:" << endl;
cin>> L2;
cout<< "Colums :" << endl;
cin>> C2;
int mx2 [L2][C2];
cout<<endl;
for (int m=0; m<L2; m++){
for (int n=0; n<C2; n++){
cout<< "Matrix element " << m+1 << " , " << n+1 <<endl;
cin>> mx2 [m][n];
cout<< endl;}}
for (int m=0; m<L2; m++){
for (int n=0; n<C2; n++){
cout<< mx2 [m][n]; }
cout<<endl;}
calc (mx2);
}//Eo B
void calc (int a[][C1], int b[][C2]){ // <-------------------
/*
Here is the tricky part, for what i've seen and read i believe
that this should be right but unfortunately it just doesnt work
//using Dev-C++ 4.9.9.0>
*/
system("cls");
}//Eo calc
void menu (){
int opt;
cout<< "Main menu:" << endl;
cout<< "1 - Mx A" << endl;
cout<< "2 - Mx B" << endl;
cout<< "3 - Calc "<< endl;
cin>> opt;
if (opcao == 1) {mxa();}
else if (opcao ==2) {mxb ();}
else if (opcao == 3) { calc ();}
}//Eo Mmenu
int main(){
system("cls");
cout<< "Mx Calc 0.9 RC"<< endl;
cout<< "****************"<< endl;
cout<< endl;
menu ();
system("PAUSE");
return 0;
}