Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "time.h"
- #include "stdlib.h"
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- using namespace std;
- int v1[100][100],x,y,columnas[100],auxy=0,mayor=0,cMayor[100],menor=0,cMenor[100],b,f=0,cont=0,menorRedo[100];
- void mostrarResultado()
- {
- for(int i=0;i<y;i++)
- {
- cout<<"La suma total de la columna"<<i+1<<" es:"<<columnas[i]<<endl;
- cout<<"Promedio de la Columna: "<<i+1<<" es: "<<columnas[i]/y<<endl;
- cout<<"EL numero mayor de la columna "<<i+1<<" es "<<cMayor[i]<<endl;
- cout<<"EL numero menor de la columna "<<i+1<<" es "<<cMenor[i]<<endl;
- cout<<"El numero menor de la columna "<<i+1<<" Se repite "<<menorRedo[i]<<" veces en toda la matriz"<<endl;
- cout<<endl;
- }
- }
- int main(int argc, char** argv) {
- cout<<"Digite el tamaño de X: "<<endl;
- cin>>x;
- cout<<"Digite el tamaño de Y: "<<endl;
- cin>>y;
- system("cls");
- srand(time(NULL));
- for(int j=0;j<y;j++) //LLENAR MATRIZ
- {
- for(int i=0;i<x;i++)
- {
- system("cls");
- v1[i][j] = rand()%21;
- }
- }
- system("cls");
- cout<<"Matriz M"<<endl; //IMPRIME MATRIZ
- for(int j=0;j<y;j++)
- {
- for(int i=0;i<x;i++)
- {
- cout<<"\t"<<v1[i][j];
- }
- cout<<"\n";
- }
- cout<<"\n\n";
- b=1;
- for(int j=0;j<y;j++)
- {
- auxy=0;
- for(int i=0;i<x;i++)
- {
- if(b==1)
- {
- menor=v1[j][i];
- b=0;
- }
- if(v1[j][i]>mayor)
- {
- mayor=v1[j][i];
- }
- if(v1[j][i]<menor)
- {
- menor=v1[j][i];
- }
- auxy=v1[j][i]+auxy;
- }
- columnas[j]=auxy;
- cMayor[j]=mayor;
- cMenor[j]=menor;
- mayor=0;
- b=1;
- cout<<"\n";
- }
- cout<<"\n";
- for(int f=0;f<y;f++)
- {
- for(int i=0;i<y;i++)
- {
- for(int j=0;j<x;j++)
- {
- if(cMenor[f]==v1[j][i])
- {
- cont++;
- }
- }
- }
- menorRedo[f]=cont;
- cont=0;
- }
- mostrarResultado();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement