This repository was archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValentina Vispo.cpp
More file actions
136 lines (125 loc) · 3.34 KB
/
Valentina Vispo.cpp
File metadata and controls
136 lines (125 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include <iostream>
#include <iomanip>
using namespace std;
/*
Alumna: Valentina Solange Vispo.
Matricula/DNI: 42.475.060
*/
const int N=50;
void cargar_matriz (int x, int matrizv[N][N]);
void Perimetro (int [N] [N], int, int&, int&);
void EncontrarMax (int [N] [N], int, int&, int&);
void Evoluciona (int matriz_Evo[N][N], int a, int b, int c, int d);
void mostrar_matriz (int tamano_matrizp, int matrizp[N][N]);
int main ()
{
int matriz[N][N], suma1=0, contar=0, max, posicion;
int matriz_peri[N][N], matrizEvo [N][N], tamano_matriz=0;
cout<<"Ingrese la dimension que desea para el arreglo: ";
cin>>tamano_matriz;
while (tamano_matriz<0 || tamano_matriz>50)
{
cout<<" Ingreso un valor de dimension invalido!!";
cout<<endl<<" Ingrese un valor mayor a 0 y menor a 50: "<<endl;
cin>>tamano_matriz;
}
//int matrizv[tamano_matriz][tamano_matriz];
cargar_matriz(tamano_matriz, matriz);
mostrar_matriz (tamano_matriz, matriz);
Perimetro (matriz, tamano_matriz, suma1, contar);
cout<<endl<<"La suma de los valores del perimetro de la matriz es igual a: "<<suma1;
cout<<endl<<"Y la cantidad de elementos que se sumaron fueron: "<<contar;
EncontrarMax (matriz, tamano_matriz, max, posicion);
cout<<endl<<"El max es: "<<max<<" y la posicion de fila en el arreglo es: "<<posicion<<endl;
//matrizEvo=matriz;
// Evoluciona (int matriz_Evo [N][N], int a, int b, int c, int d)
//Evoluciona (matriz_Evo, suma1, contar, max, posicion);
}
// Definiciones de Funciones
void cargar_matriz(int x, int matrizv[N][N]) // Carga la matriz;
{
for (int i=0; i<x; i++) // Recorre filas del arreglo;
{
for (int j=0; j<x; j++) // Recorre columnas del arreglo;
{
cout<<endl<<"Ingrese el elemento "<<"("<<i<<","<<j<<") (fila "<<i<<" y columna ";
cout<<j<<"): ";
cin>>matrizv[i][j];
while (matrizv[i][j]<0 || matrizv[i][j]>100)
{
cout<<" Ingreso un valor invalido!!";
cout<<endl<<" Ingrese un valor mayor a 0 y menor a 100: "<<endl;
cin>>matrizv[i][j];
}
}
}
}
void mostrar_matriz (int tamano_matrizp, int matrizp[N][N]) // Muestra la matriz en consola
{
for (int i=0; i<tamano_matrizp; i++)
{
cout<<endl;
for (int j=0; j<tamano_matrizp; j++)
{
cout<<setw(3)<<matrizp[i][j];
}
}
}
// Funcion 1
void Perimetro (int matriz_perimetro[N][N], int tamano, int&suma1, int&contar)
{
// Recorre el perimetro de la matriz
for (int i=0; i<tamano; i++) // 0-2
{
for (int j=0; j<tamano; j++) // 0-2
{
if (i==j && j!=0 && j+1!=tamano)
{
cout<<endl;
}
else
{
suma1+=matriz_perimetro[i][j];
contar+=1;
}
}
}
}
// Funcion 2
void EncontrarMax (int matriz2[N][N], int tamano, int&max, int&posicion)
{
max=matriz2[0][0];
//int posicion[tamano];
//Recorrer la diagonal principal
for (int i=0; i<tamano; i++)
{
for ( int j=1; j<tamano; j++)
{
if (i==j)
{
if (matriz2[i][j]>max)
{
max=matriz2[i][j];
posicion=j;
}
posicion=j;
}
}
}
}
// Funcion 3
/*
void Evoluciona (int matriz_Evo [N][N], int a, int b, int c, int d)
// (matriz_Evo, suma1, contar, max, posicion)
{
matriz_Evo/(suma*
} */
// Copiado y pegado (ignorar)
/*for (int i=0; i<tamano_matriz; i++)
{
cout<<endl;
for (int j=0; j<tamano_matriz; j++)
{
cout<<setw(3)<<matriz[i][j];
}
}*/