Hi(sorry for bad english), I have some trouble with this i'm supposed to create 4 functions
1st print matrix
2nd count pair, non-pair numbers
3rd create an array with the sum of the non-pair rows
4th print the array
so far i have the 1, 2 and 4
my problem is the third function. i tried to create the array, but i cannot return the array to the main program, so when i call the 4th function it prints an array but not the one i should get from the third function
HELP PLZ
Thanks a lot
#include <iostream>
#include <iomanip>
using namespace std;
const int M=8;
void imprimirMatriz(int m[M][M],int T);
int imparpar(int);
void genVector(int& n[], int c);
void impriVector(int v[M]);
int main()
{
int m[M][M], t, i, j, t0, ti, tp, com, V[M];
t0=0;
ti=0;
tp=0;
do
{
cout<<"Ingrese la dimensión para su matriz cuadrada"<<endl
<<"Esta debe ser un número entero entre el 1 y el 8 inclusive"
<<endl;
cin>>t;
}
while(t<1&&t>8);
cout<<"Ingrese los números para la matriz de dimensión " <<t <<endl
<<"Los números deben estar ordenados por columna" <<endl
<<"empezando por los " <<t
<<" números de la columna izquierda" <<endl
<<"Presione la tecla ENTER después de cada número ingresado"
<<endl;
for (i=0; i<t; i++)
for (j=0; j<t; j++)
cin>>m[j][i];
imprimirMatriz (m, t);
for (i=0; i<t; i++)
for (j=0; j<t; j++)
{
com=imparpar(m[i][j]);
switch(com)
{
case 0:
t0++;
break;
case 1:
ti++;
break;
case 2:
tp++;
break;
}
}
cout<<"El total de \"0\'s\" es "<<t0<< endl;
cout<<"El total de números pares es "<<tp<< endl;
cout<<"El total de números impares es "<<ti<< endl;
genVector (V, t);
cout<<"Las sumas de los números mayores que 0 de las filas impares son"<<endl;
impriVector(V);
return 0;
}
void imprimirMatriz (int m[M][M],int T)
{
int i, j;
cout<<"-----IMPRIMIENDO MATRIZ-----";
for (i=0; i<T; i++)
{
cout<<endl;
for (j=0; j<T; j++)
cout<<setw(4)<<m[i][j];
}
cout<<endl;
}
Please, always use codetags (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.