Documentos de Académico
Documentos de Profesional
Documentos de Cultura
#include <iostream>
using namespace std;
int main() {
const int S = 101;
int cont[S] = {0};
int i;
cout << "Enter integers between 1 and 100 :" << endl;
cin >> i;
while (i != 0) {
if (i >= 1 && i <= 100) {
cont[i]++;
}
cin >> i;
}
return 0;
}
Exercise 2
#include <iostream>
int main() {
int t = 10; // Tamaño del arreglo
int numeros[t]; // Arreglo para almacenar los números distintos
int cont = 0; // Contador de números distintos
int num;
return 0;
}
Exercice 3
#include <iostream>
#include <algorithm>
//ejer 3
using namespace std;
int main() {
const int TAM = 10;
int matriz[TAM];
return 0;
}
Exercice 4
#include <iostream>
using namespace std;
const int f = 3;
const int c = 4;
return 0;
}
Exercice 5
#include <iostream>
#include <algorithm>
using namespace std;
//ejer 5
int main() {
int horas_semanales[NUM_EMPLEADOS][NUM_DIAS] = {
{8, 7, 8, 6, 8, 5, 7},
{6, 6, 7, 5, 6, 6, 5},
{8, 8, 8, 8, 8, 8, 8},
{4, 4, 4, 4, 4, 4, 4},
{10, 10, 10, 10, 10, 10, 10},
{3, 3, 3, 3, 3, 3, 3},
{9, 9, 9, 9, 9, 9, 9},
{7, 7, 7, 7, 7, 7, 7}
};
int totales_horas[NUM_EMPLEADOS];
for (int i = 0; i < NUM_EMPLEADOS; i++) {
int total = 0;
for (int j = 0; j < NUM_DIAS; j++) {
total += horas_semanales[i][j];
}
totales_horas[i] = total;
}
return 0;
}
Exercice 6
#include <iostream>
using namespace std;
//ejer 6
const int ROWS = 3;
const int COLS = 3;
int main() {
double matriz1[ROWS][COLS];
double matriz2[ROWS][COLS];
double matriz_suma[ROWS][COLS];
Exercice 7
#include <iostream>
using namespace std;
//ejer 7
const int ROWS = 3;
const int COLS = 3;
int main() {
double matriz1[ROWS][COLS], matriz2[ROWS][COLS], producto[ROWS][COLS]
= {0};
// Mostrar el producto
cout << "El producto de las dos matrices es:" << endl;
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
cout << producto[i][j] << " ";
}
cout << endl;
}
return 0;
}
Exercice 8
#include <iostream>
using namespace std;
int main() {
int filas, columnas;
cout << "Ingrese el numero de filas: ";
cin >> filas;
cout << "Ingrese el numero de columnas: ";
cin >> columnas;
// Crear matriz
int** m = new int*[filas];
for (int fila = 0; fila < filas; fila++) {
m[fila] = new int[columnas];
for (int columna = 0; columna < columnas; columna++) {
cout << "Ingrese el elemento (" << fila << ", " << columna << "): ";
cin >> m[fila][columna];
}
}
// Liberar memoria
for (int fila = 0; fila < filas; fila++) {
delete[] m[fila];
}
delete[] m;
delete[] max;
return 0;
}
Conclusions
functions are fundamental to code development, as are vectors and matrices, since they
can be used as the tools they are for solving most problems.