Fazer download em txt, pdf ou txt
Fazer download em txt, pdf ou txt
Você está na página 1de 2

#include <iostream>

using namespace std;

//Um procedimento para preencher a matriz.


void PreencheMatriz (int Matriz[][])
{
for (int L=0;L<3;L++)
{
for (int C=0;C<4;C++)
{
cout<<"\n Informe o valor da coluna "<<C<<" da linha "<<L<<endl;
cin>>Matriz[L][C];
}
}
}

//Um procedimento para exibir a matriz.


void ExibeMatriz (int Mz[][])
{
cout<<"\n Esta � a Matriz: "<<endl;
for (int L=0;L<3;L++)
{
for (int C=0;C<4;C++)
{
cout<<Mz[L][C]<<" ";
}
cout<<endl;
}
}

//Um procedimento para preencher o vetor.


void PreencheVetor (int Ma[][], int Ve[])
{
for (int C=0;C<4;C++)
{
Ve[C]=0;
for (int L=0;L<3;L++)
{
Ve[C]=Ve[C]+Ma[L][C];
}
}
}

//Um procedimento para exibir o vetor.


void MostraVetor (int Vetor[])
{
cout<<"\n O vetor das somas das linhas da Matriz ficou: "<<endl;
for (int i=0;i<3;i++)
{
cout<<" "<<Vetor[i];
}
}

//Uma fun��o para calcular a qtde de valores negativos do vetor.


int CalculaNegativos (int Vetor[])
{
int qtdn=0;
for (int i=0;i<3;i++)
{
if (Vetor[i]<0)
{
qtdn++;
}
}
return qtdn;
}

// Procedimento principal
void main()
{
int M[3][4], Soma[3], Negativos;

PreencheMatriz(M);
PreencheVetor(M,Soma);
Negativos=CalculaNegativos(Soma);
ExibeMatriz(M);
MostraVetor(Soma);
cout<<"\n A quantidade de n�meros negativos � "<<Negativos<<endl;

system("pause");
}

Você também pode gostar