Вы находитесь на странице: 1из 5

Jhon Sebastián Lizarazo – 1202167

Brehilen David Carretero león- 1202158


Leandro Arévalo - 1202168

SOLUCION TALLER DE REPASO


EJERCICIO 1
#include<iostream>
#include<locale.h>
#include<math.h>
using namespace std;
int main(){
int pan = 60, ja = 22, que = 25, m = 21, c[2], j = 0, q = 0, p = 0, M = 0;
for (int i = 0; i < 21; i++)
{
pan = pan - 2;
ja = ja - 1;
que = que - 1;
m = m - 1;
M = M++;

}
q = M;
for (int i = 0; i < ja; i++)
{
pan = pan - 2;
ja = ja - 1;
que = que - 1;
m = m - 1;
p = p++;
c[0] = M;
c[1] = p;
}
j = p;
cout << endl;
cout << " COMPLETOS INCOMPLETOS(3 INGREDIENTES)" << endl;
cout << "EMPANEDADOS";
for (int i = 0; i < 2; i++)
{
cout <<" "<< c[i];
}
cout << endl<<endl;

system("pause");
return 0;
}

EJERCICIO 2
#include<iostream>
#include<locale.h>
#include<math.h>
#include<time.h>
using namespace std;
int main() {
setlocale(LC_ALL, "");
srand(time(NULL));
Jhon Sebastián Lizarazo – 1202167
Brehilen David Carretero león- 1202158
Leandro Arévalo - 1202168
int a[5], b[100], c = 0, d = 0, s = 0, m = 0, l = 0;
cout << endl;
cout << " Los 100 números" << endl<<endl;
for (int i = 0; i < 100; i++)
{

b[i] = rand() % 5 + 1;
cout << " " << b[i];
if (b[i] == 1)
{
c++;
}
else
{
if (b[i] == 2)
{
d++;
}
else
{
if (b[i] == 3)
{
m++;
}
else
{
if (b[i] == 4)
{
l++;
}
else
{
s++;
}
}
}
}
}
for (int i = 0; i < 1; i++)
{
a[0] = c;
a[1] = d;
a[2] = m;
a[3] = l;
a[4] = s;
}
cout << endl << endl;
cout << " UNO DOS TRES CUATRO CINCO" << endl;
cout << "VECES";
for (int i = 0; i < 5; i++)
{
cout << " " << a[i]<< " ";
}
cout << endl;
system("pause");
return 0;
}
Jhon Sebastián Lizarazo – 1202167
Brehilen David Carretero león- 1202158
Leandro Arévalo - 1202168

EJERCICIO 3
#include<iostream>
#include<locale.h>
#include<math.h>
#include<time.h>
using namespace std;
int main() {
setlocale(LC_ALL, "");
srand(time(NULL));
int a[4][4],s,p=0;
cout << endl;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
a[i][j] = rand() % 50 + 1;
}
}
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
for (int k = i; k < 4; k++)
{
p = 0;
if (i==k)
{
p = j + 1;
}
for (int m = p; m < 4; m++)
{
if (a[i][j]>a[k][m])
{
s = a[k][m];
a[k][m] = a[i][j];
a[i][j] = s;
}
}
}
}
}
cout << " LA TABLA ORGANIZADA" << endl<<endl;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
cout << " " << a[i][j];
}
cout << endl;
}
system("pause");
return 0;
}
Jhon Sebastián Lizarazo – 1202167
Brehilen David Carretero león- 1202158
Leandro Arévalo - 1202168
EJERCICIO 4
#include<iostream>
#include<locale.h>
#include<math.h>
#include<time.h>
using namespace std;
int main() {
setlocale(LC_ALL, "");
srand(time(NULL));
int opc, a, c, b[100], z = 0,x;
do {
cout << endl;
cout << " MENU" << endl << endl;
cout << " 1. Ingresar datos a un arreglo" << endl;
cout << " 2. Listar los datos ingresados al arreglo" << endl;
cout << " 3. Sumar todos los datos e imprimir el arreglo" << endl;
cin >> opc;
system("cls");
switch (opc)
{
case 1:
cout << endl;
cout << " ¿Cuantos datos va ingresar en el arreglo?"
<< endl;
cin >> a;
system("cls");
cout << endl;
cout << " Por favor ingrese los datos" << endl;
for (int i = 0; i < a; i++)
{
cin >> c;
b[i] = c;
}
system("cls");
cout << endl;
cout << " Los datos que usted ingresó son los
siguientes" << endl;
for (int i = 0; i < a; i++)
{
cout << " " << b[i];
}
cout << endl;
break;
case 2:
cout << endl;
cout << " ¿Cuantos datos va ingresar en el arreglo?"
<< endl;
cin >> a;
system("cls");
cout << endl;
cout << " Por favor ingrese los datos" << endl;
for (int i = 0; i < a; i++)
{
cin >> c;
b[i] = c;
}
Jhon Sebastián Lizarazo – 1202167
Brehilen David Carretero león- 1202158
Leandro Arévalo - 1202168
system("cls");
cout << endl;
cout << " Los datos que usted ingresó quedarón en el
siguiente orden" << endl;
for (int i = 0; i < a; i++)
{
cout << i + 1 << ". " << b[i] << endl;
}
break;
case 3:
cout << endl;
cout << " ¿Cuantos datos va ingresar en el arreglo?"
<< endl;
cin >> a;
system("cls");
cout << endl;
cout << " Por favor ingrese los datos" << endl;
for (int i = 0; i < a; i++)
{
cin >> c;
b[i] = c;
}
system("cls");
cout << endl;
cout << " Los datos que usted ingresó son los
siguientes" << endl << endl;
cout << " ";
for (int i = 0; i < a; i++)
{
cout << " " << b[i];
}
for (int i = 0; i < a; i++)
{
z = b[i] + z;
}
cout << endl << endl;
cout << " Y la suma entre todos ellos da como
resultado = " << z << endl;
break;
default:
cout << endl;
cout << " Ingresó una opcion incorrecta" <<
endl;
break;
}
cout << endl;
cout << " Desea volver a repetir alguna opcion 1=si 2=no" <<
endl;
cin >> x;
system("cls");
} while (x == 1);
system("pause");
return 0;
}

Вам также может понравиться