Advertisement
svaltqt

Quiz practico 3

Nov 22nd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include "time.h"
  3. #include "stdlib.h"
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. using namespace std;
  7.  
  8. 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];
  9.  
  10.  
  11. void mostrarResultado()
  12. {
  13. for(int i=0;i<y;i++)
  14. {
  15. cout<<"La suma total de la columna"<<i+1<<" es:"<<columnas[i]<<endl;
  16. cout<<"Promedio de la Columna: "<<i+1<<" es: "<<columnas[i]/y<<endl;
  17. cout<<"EL numero mayor de la columna "<<i+1<<" es "<<cMayor[i]<<endl;
  18. cout<<"EL numero menor de la columna "<<i+1<<" es "<<cMenor[i]<<endl;
  19. cout<<"El numero menor de la columna "<<i+1<<" Se repite "<<menorRedo[i]<<" veces en toda la matriz"<<endl;
  20. cout<<endl;
  21.  
  22. }
  23. }
  24. int main(int argc, char** argv) {
  25.  
  26.  
  27. cout<<"Digite el tamaño de X: "<<endl;
  28. cin>>x;
  29. cout<<"Digite el tamaño de Y: "<<endl;
  30. cin>>y;
  31. system("cls");
  32. srand(time(NULL));
  33. for(int j=0;j<y;j++) //LLENAR MATRIZ
  34. {
  35. for(int i=0;i<x;i++)
  36. {
  37. system("cls");
  38. v1[i][j] = rand()%21;
  39. }
  40.  
  41. }
  42. system("cls");
  43.  
  44.  
  45. cout<<"Matriz M"<<endl; //IMPRIME MATRIZ
  46. for(int j=0;j<y;j++)
  47. {
  48. for(int i=0;i<x;i++)
  49. {
  50. cout<<"\t"<<v1[i][j];
  51. }
  52. cout<<"\n";
  53. }
  54. cout<<"\n\n";
  55.  
  56. b=1;
  57. for(int j=0;j<y;j++)
  58. {
  59. auxy=0;
  60. for(int i=0;i<x;i++)
  61. {
  62.  
  63. if(b==1)
  64. {
  65. menor=v1[j][i];
  66. b=0;
  67. }
  68. if(v1[j][i]>mayor)
  69. {
  70. mayor=v1[j][i];
  71. }
  72. if(v1[j][i]<menor)
  73. {
  74. menor=v1[j][i];
  75. }
  76. auxy=v1[j][i]+auxy;
  77. }
  78. columnas[j]=auxy;
  79. cMayor[j]=mayor;
  80. cMenor[j]=menor;
  81. mayor=0;
  82. b=1;
  83. cout<<"\n";
  84. }
  85. cout<<"\n";
  86.  
  87. for(int f=0;f<y;f++)
  88. {
  89. for(int i=0;i<y;i++)
  90. {
  91. for(int j=0;j<x;j++)
  92. {
  93.  
  94. if(cMenor[f]==v1[j][i])
  95. {
  96. cont++;
  97. }
  98.  
  99. }
  100. }
  101. menorRedo[f]=cont;
  102. cont=0;
  103. }
  104. mostrarResultado();
  105.  
  106.  
  107.  
  108.  
  109.  
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement