Está en la página 1de 2

Luis Felipe Gonzalez Latorre – Juan Nicolas Rojas Arango – Mec A

Programación
Punto 5:

#include <iostream>

using namespace std;

int main()

{
int J[25] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
int x = 0;

for (int x = 0; x < 25; x++) {

cout << j[x] << endl;

return 0;
}

18. Escribir un programa que divida todos los elementos de una matriz M (3,4) por el
elemento situado en la posición (2,2). Validar la división por 0
#include <iostream>
using namespace std;
int main()

{
int M [3][4];
int x = 0;
int y = 0;

for (int x = 0; x < 3; x++) {


for (int y = 0; y < 4; y++) {
cout << "ingrese el valor de la fila " << x
<< " y la columna " << y << endl;
cin >> M[x][y];
}
}

cout << "la matriz M (3,4) quedaria :"<< endl;


for (int x = 0; x < 3; x++) {
for (int y = 0; y < 4; y++) {
cout << M[x][y] << " ";
}
cout << endl;
}
cout << "la matriz M (3,4), dividiendo todas las casillas por la casilla (2,2) quedaria :" << endl;
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 4; y++) {
else
M[x][y] = M[x][y] / M[2][2];
cout << M[x][y] << " ";
}
cout << endl;
}
return 0;
}

20. Determinar la posición del elemento más grande de un arreglo M de 4 filas por 3
columnas, que contiene solamente números enteros. Los valores de los elementos de la
matriz se asignan en la declaración

#include <iostream>
using namespace std;

int main()
{
int M[4][3]={{8,45,46},{144,52,25},{35,86,15},{87,6,32}};

for (int x = 0; x < 4; x++) {


for (int y = 0; y < 3; y++) {
cout << M[x][y] << " ";

if (M[x][y]>M[0][0]){

M[0][0]=M[x][y];
}

cout << endl;


}

cout << "el numero mayor es: ";


cout << M[0][0] << endl;
return 0;
}

También podría gustarte