Está en la página 1de 63

EJERCICIO REALIZADOS EN CLASE

1. CORRECCIÓN TABLA DEL 5 CON 10 PRODUCTOS.


// ConsoleApplication29.cpp: archivo de proyecto principal.
#include "stdafx.h" // grupo de
#include <iostream>
#include<conio.h>// directivas
using namespace System; // necesarias para
using namespace std; // compilacion
int main()
{
int L, p; // definición variables del programa
Console::Clear;
Console::WriteLine(L"Tabla del 5 con 10 productos");
L = 1;
do { //do para repetir 10 veces
p = L * 5;
cout << L << " * 5 = " << p<<endl; //imprimir cada producto
L = L + 1;

} while (L<11); //fin del repetidor 10 veces

getch();
}

2. N TABLAS DE MULTIPLICAR CON 20 PRODUCTOS.

#include "stdafx.h"
#include "iostream"
#include<conio.h>
using namespace System;
using namespace std;
int main()
{
int n, t, m, p;
Console::WriteLine(L"Tablas de 1 a N con 20 productos");
cout << "Tecle n (numero de tablas) = a ";
cin >> n;
for (t = 1; t <= n; t = t + 1) // hacer c/u de las n tablas
{
cout << " Tabla del " << t << " con 20 productos" << endl;
for (m = 1; m <= 20; m = m + 1) // cada multiplicando
{
p = m*t;
cout << m << " * " << t << " = " << p << endl;
} // fin del for m 20 productos de cada tabla
cout << " Pulse tecla para seguir";
getch();
Console::Clear(); // ver cada tabla por pantalla
} // fin del for t tablas del 1 al n
}
3. CORRECCIÓN RAÍCES DE UNA FUNCIÓN GRADO DOS.
#include "stdafx.h"
#include "iostream"
#include<conio.h>;
#include<math.h>; // librería de funciones matemáticas
using namespace System;
using namespace std;
int main()
{
float a, b, c, x1, x2, r, t;
Console::WriteLine(L"Solución ecuación de segundo orden");
cout << "\n Tecle coeficiente a = ";
cin >> a;
cout << "\n Tecle coeficiente b = ";
cin >> b;
cout << "\n Tecle coeficiente c = ";
cin >> c;
r = b*b - 4 * a*c; // calcular discriminante
if (r >= 0) // la raíz esta en el campo de los reales
{
t = sqrt(r); // raíz cuadrada del discriminante
x1 = (-1 * b + t) / 2 * a; // dos raíces + - según fórmula
x2 = (-1 * b - t) / 2 * a;
cout << "\n Raíz X1 = " << x1 << "\n Raíz X2 = " << x2;
}
else {
cout << "\n Ecuación tiene raíces imaginarias ";
}
getch();
}
4. ENCONTRAR EL MAYOR Y EL MENOR DE UN VECTOR (A) Y
SU POSICIÓN (B).
#include "stdafx.h"
#include "iostream"
#include<conio.h>
using namespace System;
using namespace std;
int main()
{
int A[100], i, n, p1, p2, may, men; // definición de variables, Vector A de
hasta 100 datos
Console::WriteLine(L"Hallar el mayor y menor elemento de un ");
Console::WriteLine(L"Vector A de n elementos, indicando la ");
Console::WriteLine(L"posición que tienen en el Vector. ");
cout << "\n Teclee el número de datos n = ";
cin >> n;
for (i = 1; i <= n; i = i + 1) // Lectura del Vector A de n elementos
{
cout << "Dato " << i << " = ";
cin >> A[i];
}
may = A[1]; //Se supone el primer dato como mayor y menor
men = A[1];
p1 = 1;
p2 = 1;
for (i = 2; i <= n; i = i + 1) // Hallar mayor y menor al tiempo.
{
if (A[i]>may)
{
may = A[i];
p1 = i; // Guardar la posición del mayor
}
else {
if (A[i]<men)
{
men = A[i];
p2 = i; // Guardar la posición del menor
}
}
} // fin del for i, para comparar todos
cout << "El mayor es " << may << " y esta en la posición " << p1 << endl;
cout << "El menor es " << men << " y esta en la posición " << p2 << endl;
getch(); // parada temporal hasta pulsar tecla (visualizar la solución)
}

5. PRODUCTO MATRIZ.

// ConsoleApplication25.cpp: archivo de proyecto principal.

#include "stdafx.h"
#include "iostream"
#include<conio.h>;
using namespace System;
using namespace std;
int main()
{
int a[10][10], b[10][10], c[10][10];// definicion de Matrices a, b, c, hasta
10x10 elementos
int i, j, n, m, k, l, x;
// Se lee el orden de la matriz a ( n x m )
Console::Write(L" Numero de filas de la matriz a n = "); cin >> n;
Console::Write(L" Numero de columnas m = "); cin >> m;
// Se lee el orden de la matriz b ( k x l )
Console::Write(L" Numero de filas de la matriz b k = "); cin >> k;
Console::Write(L" Numero de columnas l = "); cin >> l;
/* Proceso para calcular el producto de dos matrices a y b. El producto es
posible solo si (m) numero de columnas de la matriz que premultiplica (a),
es igual al numero de filas (k) de la matriz (b) que posmultiplica.
Se verifica si m=k ==> cumplen la condicion anterior, y se pueden
multiplicar,
siendo el resultado la matriz c de orden nxl.
*/
if (m == k) { // si se pueden muiltiplicar, se leen las dos matrices
cout << "\nTeclear datos de la matriz a";
for (i = 1; i <= n; i = i + 1) // aqui seria ==> hasta n filas para a
{
for (j = 1; j <= m; j = j + 1) // aqui seria ==> hasta m
columnas
{
cout << "\n dato a[" << i << "][" << j << "] = ";
cin >> a[i][j];
}
}
// se lee la matriz b de orden k x l
cout << "\nTeclear datos de la matriz b";
for (i = 1; i <= k; i = i + 1) // aqui seria ==> hasta k filas
{
for (j = 1; j <= l; j = j + 1) // aqui seria ==> hasta l columnas
{
cout << "\n dato b[" << i << "][" << j << "] = ";
cin >> b[i][j];
}
}
// inicia proceso para producto de axb
for (i = 1; i <= n; i = i + 1) // aqui seria ==> hasta n filas
{
for (j = 1; j <= l; j = j + 1) // aqui seria ==> hasta l columnas
{
c[i][j] = 0; // para acumular cada elemento de c
for (x = 1; x <= m; x = x + 1)
{
c[i][j] = c[i][j] + a[i][x] * b[x][j];
}// cada elemento de c es igual Suma del producto
// de los elementos de la fila de a por los de la
// columna de b
}
}
// Proceso par imprimir la matriz suma c
cout << "La matriz c producto de a x b es: " << endl;
for (i = 1; i <= n; i = i + 1) // imprimir c/u de las n filas
{
for (j = 1; j <= l; j = j + 1) // l columnas
{
cout << " " << c[i][j]; //imprime cada elemento de la
respectiva fila
} //separado por un espacio
cout << "\n"; // para cambiar a nueva linea de impresion en la
patalla
}
}// cierre del if
else { // no se pueden multiplicar (diferente columnas de a con filas de b))
cout << "\nNo se pueden Multiplicar; matrices de distinto orden";
}
cout << "\n Termina programa";
getch();
}

6. SUMA MATRIZ.

#include "stdafx.h"
#include "iostream"
#include<conio.h>;
using namespace System;
using namespace std;
int main()
{
int a[10][10], b[10][10], c[10][10];// definicion de Matrices a, b, c, hasta 10x10
elementos
int i, j, n, m, k, l;
// Se lee el orden de la matriz a ( n x m )
Console::Write(L" Numero de filas de la matriz a n = "); cin >> n;
Console::Write(L" Numero de columnas m = "); cin >> m;
// se lee la matriz a de orden n x m
for (i = 1; i <= n; i = i + 1) // aqui seria ==> hasta n filas
{
for (j = 1; j <= m; j = j + 1) // aqui seria ==> hasta m columnas
{
cout << "\n dato a[" << i << "][" << j << "] = ";
cin >> a[i][j];
}
}
// Se lee el orden de la matriz b ( k x l )
Console::Write(L" Numero de filas de la matriz b k = "); cin >> k;
Console::Write(L" Numero de columnas l = "); cin >> l;
// se lee la matriz b de orden k x l
for (i = 1; i <= k; i = i + 1) // aqui seria ==> hasta k filas
{
for (j = 1; j <= l; j = j + 1) // aqui seria ==> hasta l columnas
{
cout << "\n dato b[" << i << "][" << j << "] = ";
cin >> b[i][j];
}
}
/* Proceso para calcular la suma de los dos matrices a y b
La suma de dos matrices a y b es otra matriz c (c = a + b)
Primero se verifica si son del mismo orden, de lo contrario
no se pueden sumar
*/
if (n == k) {
if (m == l) {// si se pueden sumar (son del mismo orden)
// Proceso para la suma de dos matrices
for (i = 1; i <= n; i = i + 1) // aqui seria ==> hasta n, o k filas
{
for (j = 1; j <= m; j = j + 1) // aqui seria ==> hasta m, o l
columnas
{
c[i][j] = a[i][j] + b[i][j]; //Suma elemento a elemento
por fila
}
}
// Proceso par imprimir la matriz suma c
cout << "La matriz c suma de a + b es: " << endl;
for (i = 1; i <= n; i = i + 1) // imprimir c/u de las n filas
{
for (j = 1; j <= m; j = j + 1) // m columnas
{
cout << " " << c[i][j]; //imprime cada elemento de la
respectiva fila
} //separado por un espacio
cout << "\n"; // para cambiar a nueva linea de impresion en la
patalla
}
}// del if interno
else { // del if interno (no se pueden sumar(igual filas pero diferentes
columnas))
cout << "\nNo se pueden sumar matrices de distinto orden";
//getch();break; // romper proceso para salir
}
}// del 1er if
else {// del 1er if (no se pueden sumar(diferentes filas))
cout << "\nNo se pueden sumar matrices de distinto orden";
//getch();break; // romper proceso para salir
}
cout << " Termina programa";
getch();
}
7. MATRIZ NÚMEROS CONSECUTIVOS 9*9.

#include "stdafx.h"
#include "iostream"
#include<conio.h>;
using namespace System;
using namespace std;
int main()
{
int a[9][9];// definicion de Matrices a de 9x9
int i, j; // definicion de subindice i, j enteros
// Proceso para construir la matriz de la figura 1
for (i = 1; i <= 9; i = i + 1) // aqui varia segun las filas (aqui 9)
{
for (j = 1; j <= 9; j = j + 1) // varia segun las colunbas (aqui 9)
{
a[i][j] = i; // c/elemento igual al valor de la fila
} //termina for j de columnas
} // termina for i de filas
// Proceso par imprimir la matriz a (figura 1)
cout << "La matriz a de la figura 1 es:" << endl;
for (i = 1; i <= 9; i = i + 1) // imprimir c/u de las 9 filas
{
for (j = 1; j <= 9; j = j + 1) // 9 columnas
{
cout << " " << a[i][j]; //imprime cada elemento de la
respectiva fila
} //separado por un espacio
cout << "\n"; // para cambiar a nueva linea de impresion en la patalla
}
cout << "\n Termina programa";
getch();
}
8. MATRIZ IDENTIDAD.

#include "stdafx.h"
#include "iostream"
#include<conio.h>;
using namespace System;
using namespace std;
int main()
{
int A[10][10], i, j, n; // definicion de variables, Matriz A de hasta 10x10
elementos
// No se lee la matriz identidad
de orden N; sino que se hace la matriz.
// Matriz de orden n, quiere decir
matriz cuadrada de orden n (n x n )
// NOTA: 1a forma de hacer el
programa.
Console::Write(L" orden de la matriz identidad que desea n = ");
cin >> n;
for (i = 1; i <= n; i = i + 1) // aqui seria ==> hasta n filas
{
for (j = 1; j <= n; j = j + 1) // aqui seria ==> hasta n ( n x n)
{
if (i == j) // unos en la diagonal principal
{
A[i][j] = 1;
}
else {
A[i][j] = 0; // 0 todos los demas elementos
}
}
}

// Proceso para imprimir la matriz a de orden n


for (i = 1; i <= n; i = i + 1) // i subindice indica la fila
{
for (j = 1; j <= n; j = j + 1) // j subindice indica la respectiva columna
{
cout << " " << A[i][j]; // cada elemento de la respectiva fila
} // de la matriz separado por espacio
cout << "\n"; // saltar a nueva linea para la siguiente fila
}
getch(); // para ver el resultado hasta pulsar tecla
}
EJERCICIO EXTRA-BONUS

9. MATRIZ ROMBO, NÚMEROS CRECIENTES

#include "stdafx.h"
#include "iostream"
#include<conio.h>

using namespace System;


using namespace std;

using namespace std;


int main()
{
int a[20][20];// definicion de Matrices a de 9x9
int i, j, h, m, n, k, l, b, o, p, g, t;
// definicion de subindice i, j enteros
// Proceso para construir la matriz de la figura 1
for (i = 1; i<10; i = i + 1) // aqui varia segun las filas (aqui 9)
{
for (j = 1; j<10; j = j + 1) // varia segun las colunbas (aqui 9)
{
h = 10 - j;
a[i][j] = h; // c/elemento igual al valor de la fila
} //termina for j de columnas
}
for (i = 1; i<10; i = i + 1)
// aqui varia segun las filas (aqui 9)
{
l = 1;
for (j = 10; j<19; j = j + 1)
{
a[i][j] = l;
l = l + 1; // c/elemento igual al valor de la fila
} //termina for j de columnas
} // termina for i de filas
// Proceso par imprimir la matriz a (figura 1)
cout << "La matriz a de la figura 1 es:" << endl;

for (i = 1; i <= 9; i = i + 1) // imprimir c/u de las 9 filas


{
n = 10 - i;
b = 20 - 2 * i;
m = 10;
for (k = 1; k <= b; k = k + 1)
{
cout << " ";
}
for (j = 1; j<i + 1; j = j + 1)

// 9 columnas
{

cout << " " << a[i][n];


n = n + 1;
}
for (j = 1; j<i + 1; j = j + 1) {

cout << " " << a[i][m];


m = m + 1;//imprime cada elemento de la respectiva fila
}
//separado por un espacio
cout << "\n"; // para cambiar a nueva linea de impresion en la patalla
}

for (i = 10; i<20; i = i + 1) // aqui varia segun las filas (aqui 9)


{
for (j = 1; j<10; j = j + 1) // varia segun las colunbas (aqui 9)
{
h = 10 - j;
a[i][j] = h; // c/elemento igual al valor de la fila
} //termina for j de columnas
}
for (i = 10; i<20; i = i + 1) // aqui varia segun las filas (aqui 9)
{
h = 1;
for (j = 10; j<20; j = j + 1) // varia segun las colunbas (aqui 9)
{

a[i][j] = h;
h = h + 1;
// c/elemento igual al valor de la fila
} //termina for j de columnas
}

b = 0;
for (i = 10; i<19; i = i + 1) // imprimir c/u de las 9 filas
{
p = 10;
b = b + 2;
o = i - 9;

for (k = 1; k <= b; k = k + 1)
{
cout << " ";
}
for (j = 1; j<20 - i; j = j + 1)

// 9 columnas
{

cout << " " << a[i][o];


o = o + 1;
}
for (j = 1; j<20 - i; j = j + 1)

cout << " " << a[i][p];


p = p + 1;
}
//separado por un espacio
cout << "\n"; // para cambiar a nueva linea de impresion en la patalla
}

cout << "\n Termina programa";


getch();
}

EJERCICIOS TIPO PARCIAL PRIMER CORTE

10. ESCRIBA UN DIAGRAMA QUE GENERE 1000


NÚMEROS DE FIBONACCI Y DIGA SI LA SUMA DE
ESTOS NÚMEROS, ES UN NÚMERO PRIMO
#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;


using namespace std;

int main() {
double num, ant, gua, suma;
num = 1;
ant = 0;
cout << "los numeros de la secuecia fibonacci son ";
cout << "0 , 1 ";
for (int i = 1; i<10; i = i + 1) {

gua = num;
num = num + ant;
cout << " , " << num;
ant = gua;
suma = suma + num;

}
suma = suma + 1;
cout << " su suma es " << suma << endl;
long long f, x, sp, p, sa;
f = suma - 1;
for (long a = 2; a<suma; a = a + 1) {
x = suma / a;

sp = x*a;

if (sp == suma) {
cout << " " << suma << ", no es primo";
a = f;
sa = 0;
}
else {
sa = 1;
}
}
if (sa == 1)
{
cout << " " << suma << ", es primo";
}

getch();
}
11. PARA N NÚMEROS ENTEROS X, BUSCAR EL
MAYOR, SUMAR LA CIFRAS DEL MAYOR Y DECIR SI
ESTA SUMA DA UN NÚMERO PERFECTO.

#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {
float mayor, n, x;
int co, ci, p, sp;
cout << "¿cuantos numeros desea ingresar? "; cin >> n;
mayor = -100000000000;

for (int i = 1; i <= n; i = i + 1) {


cout << "INGRESAR LOS NUMEROS "; cin >> x;
if (x>mayor) {

mayor = x;

}
cout << "EL NUMERO MAYOR ES " << mayor << endl;
sp = 0;
co = 1;
while (co != 0) {

co = mayor / 10,
ci = co * 10;
p = mayor - ci;
sp = sp + p;
mayor = co;
}
cout << sp << endl;

int sc, pp, pl, f;


sc = 0;
f = sp - 1;
for (int i = 1; i <= f; i = i + 1) {
pp = sp / i;
pl = pp*i;
if (pl == sp) {

sc = sc + i;
}

if (sc != sp) {

cout << "EL NUMERO NO ES PERFECTO";

}
else
{
cout << "EL NUMERO ES PERFECTO";

getch();
}
12. PARA N>M HALLE COMBINATORIA (N,M) =
N!/(N-M)!, Y A ESTA SACAR RAÍZ CUADRADA SEGÚN
NEWTON(RAÍZ NEWTON DE X ES: SUPONGA UNA
RAÍZ XO, A PARTIR DE ESTA CALCULAR OTRA XN=
½(XO +X/XO) HASTA QUE |XN-XO| SEA MUY
PEQUEÑA )

#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;


using namespace std;

int main() {
float n, m, combim, combin, combia, combinatoria, a;

cout << "ingrese m y n para la combinatoria para n>m ";


cout << "ingrese n " << endl;
cin >> n;
cout << "ingrese m " << endl;
cin >> m;
a = n - m;
combim = 1;
combin = 1;
combia = 1;
for (int im = 1; im <= m; im = im + 1) {

combim = combim*im;

}
for (int in = 1; in <= n; in = in + 1) {

combin = combin*in;

} for (int ia = 1; ia <= a; ia = ia + 1) {

combia = combia*ia;

}
combinatoria = combin / combia;
cout << "la combinatoria es igual a: " << combinatoria << endl;
float raiza, raizn;
raiza = 1;
for (int z = 1; z<11; z = z + 1) {
raizn = 0.5*(raiza + combinatoria / raiza);
raiza = raizn;
}
cout << "la raiz es = " << raiza;
getch();
}
13. ESCRIBA UN DIAGRAMA QUE PARA DATOS X
( X = ÁNGULO EN GRADOS ), CALCULE PARA CADA
UNO, SUS FUNCIONES SENO, COSENO, SECANTE,
COSECANTE, TANGENTE Y COTANGENTE. HACER
FUNCIÓN SENO Y COSENO POR EL MÉTODO
NUMÉRICO DE TAYLOR

#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {
float x, a, rad, n, m, sen, cas, ton, cot, sic, csca, sent, cost;

cout << "ingrese el numero de angulos a hallar su razones trigonometricas ";


cin >> n;

for (int i = 1; i <= n; i = i + 1) {


cout << "ingrese el valor del angulo" << endl;
cin >> m;

rad = 3.141592*m / 180;


sen = sin(rad);
cout << "el seno es igual a: " << sen << endl;
cas = cos(rad);
cout << "el coseno es igual a: " << cas << endl;

if (cas == 0) {
cout << "tangente tiende a infinito" << endl;
cout << "secante tiende a infinito" << endl;
}
else {
ton = sen / cas;
cout << "tangente es igual a: " << ton << endl;
sic = 1 / cas;
cout << "secante es igual a: " << sic << endl;
}
if (sen == 0) {
cout << "cotangente tiende a infinito" << endl;
cout << "cosecante tiende a infinito" << endl;
}
else {
cot = cas / sen;
cout << "cotangente es igual a: " << cot << endl;
csca = 1 / sen;
cout << "cosecante es igual a: " << csca << endl;
}
float sx, e, d, sig, t, s, fd;
sx = 0;
e = 1;
d = 1;
sig = 1;

for (t = 1; t <= 10; t = t + 1)


{
fd = 1;
for (s = 1; s <= d; s = s + 1) {

fd = fd * s;
}
float resultado = pow(rad, e);
sx = sx + (sig*(resultado / fd));

e = e + 2;
d = d + 2;
sig = -1 * sig;
}

cout << "el seno por taylor es igual a: " << sx << endl;
sx = 1;
e = 2;
d = 2;
sig = -1;

for (t = 1; t <= 10; t = t + 1)


{
fd = 1;
for (s = 1; s <= d; s = s + 1) {

fd = fd * s;
}
float resultado = pow(rad, e);
sx = sx + (sig*(resultado / fd));

e = e + 2;
d = d + 2;
sig = -1 * sig;
}
cout << "el coseno por taylor es igual a: " << sx << endl;
}
}
14. PARA VARIOS DATOS X ( X = NÚMERO ENTERO
), ESTABLEZCA PARA CADA UNO SI ES PRIMO O NO
Y CUÁL ES EL MAYOR NÚMERO PRIMO HALLADO

#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {
float mayor, n, x;
int co, f, ci, p, sp, sa;
cout << "¿cuantos numeros desea ingresar? "; cin >> n;
mayor = 0;

for (int i = 1; i<n + 1; i = i + 1) {


cout << "INGRESAR LOS NUMEROS "; cin >> x;

f = x - 1;
for (int a = 2; a<x; a = a + 1) {
ci = x / a;

sp = ci*a;

if (sp == x) {
cout << " " << x << ", no es primo" << endl;
a = f;
sa = 0;
}
else {
sa = 1;
}
}
if (sa == 1)
{
cout << " " << x << ", es primo " << endl;

if (x>mayor) {

mayor = x;

}
}

}
cout << "el mayor de los primos es: " << mayor;
getch();
}
15. PARA N NÚMEROS, CADA UNO CON CUALQUIER
NÚMERO DE CIFRAS, HALLE CUÁNTO VALE LA
SUMA DE LAS CIFRAS DE CADA NÚMERO Y CUÁL
ES LA MENOR SUMA DE CIFRAS DE LOS NÚMEROS
#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {
float mayor, n, x, menor;
int co, ci, p, sp;

cout << "¿cuantos numeros desea ingresar? " << endl; cin >> n;
menor = 99999999999999;

for (int i = 1; i <= n; i = i + 1) {


cout << "ingrese el numero "; cin >> x;
sp = 0;
co = 1;
while (co != 0) {

co = x / 10,
ci = co * 10;
p = x - ci;
sp = sp + p;
x = co;
}
cout << "la suma de sus cifras es " << sp << endl;

if (sp<menor) {

menor = sp;

}
cout << "LA SUMA DE CIFRAS MENOR ES " << menor << endl;
getch();
}

16. PARA DATOS ENTEROS X ( SON VARIOS ) HALLE


LA CIFRA MÁS REPETIDA EN CADA NÚMERO X.
#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {
float mayor, n, x, menor;
int co, ci, p, sp, a, b, c, d, e, f, g, h, i, j, s, z;

cout << "¿cuantos numeros desea ingresar? " << endl; cin >> n;

for (int s = 1; s <= n; s = s + 1) {


cout << "ingrese el numero "; cin >> z;
sp = 0;
co = 1;
a = 0; /*0*/
b = 0; /*1*/
c = 0; /*2*/
d = 0; /*3*/
e = 0; /*4*/
f = 0; /*5*/
g = 0; /*6*/
h = 0; /*7*/
i = 0; /*8*/
j = 0; /*9*/
x = z;
while (co != 0) {

co = x / 10,
ci = co * 10;
p = x - ci;
x = co;
if (p == 0) {
a = a + 1;
}
if (p == 1) {
b = b + 1;
}if (p == 2) {
c = c + 1;
}if (p == 3) {
d = d + 1;
}if (p == 4) {
e = e + 1;
}if (p == 5) {
f = f + 1;
}if (p == 6) {
g = g + 1;
}if (p == 7) {
h = h + 1;
}
if (p == 8) {
i = i + 1;
}
if (p == 9) {
j = j + 1;
}

}
if (a >= b&&a >= c&&a >= d&&a >= e&&a >= f&&a >= g&&a >= h&&a
>= i&&a >= j&&a != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 0 " << endl;
}
if (b >= a&&b >= c&&b >= d&&b >= e&&b >= f&&b >= g&&b >= h&&b
>= i&&b >= j&&b != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 1 " << endl;
}
if (c >= b&&c >= a&&c >= d&&c >= e&&c >= f&&c >= g&&c >= h&&c
>= i&&c >= j&&c != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 2 " << endl;
}
if (d >= b&&d >= c&&d >= a&&d >= e&&d >= f&&d >= g&&d >= h&&d
>= i&&d >= j&&d != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 3 " << endl;
}
if (e >= b&&e >= c&&e >= d&&e >= a&&e >= f&&e >= g&&e >= h&&e
>= i&&e >= j&&e != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 4 " << endl;
}
if (f >= b&&f >= c&&f >= d&&f >= e&&f >= a&&f >= g&&f >= h&&f >=
i&&f >= j&&f != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 5" << endl;
}
if (g >= b&&g >= c&&g >= d&&g >= e&&g >= f&&g >= a&&g >= h&&g
>= i&&g >= j&&g != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 6 " << endl;
}
if (h >= b&&h >= c&&h >= d&&h >= e&&h >= f&&h >= g&&h >= a&&h
>= i&&h >= j&&h != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 7 " << endl;
}
if (i >= b&&i >= c&&i >= d&&i >= e&&i >= f&&i >= g&&i >= h&&i >=
a&&i >= j&&i != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 8 " << endl;
}
if (j >= b&&j >= c&&j >= d&&j >= e&&j >= f&&j >= g&&j >= h&&j >=
i&&j >= a&&j != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 9 " << endl;
}
}
getch();
}

17. PARA N NÚMEROS ENTEROS X, HALLE CUÁL ES


EL EQUIVALENTE BINARIO DE CADA X.
#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {

int a, b, c, h, ex, rta, i, z, s, t, x, n, f;


cout << "¿cuantos numeros desea ingresar? " << endl; cin >> n;

for (int s = 1; s <= n; s = s + 1) {

cout << "ingrese el numero "; cin >> z;


i = 0;
rta = 0;
ex = log2(z);
a = z;
for (int b = 0; b<ex; b = b + 1) {

if (a % 2 == 1) {
c = pow(10, b);
rta = c + rta;

}
a = a / 2;
t = b + 1;
}
x = pow(10, t);
rta = rta + x;

cout << "el binario de " << z << " es:" << rta << endl;
}
getch();
}
18. PARA NÚMEROS BINARIOS XB, HALLE CUÁL ES
EL EQUIVALENTE EN BASE 10 DE CADA BINARIO
#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {
int a, b, c, h, ex, rta, i, z, s, t, x, n, f, co, si, sp, ci, p;
cout << "¿cuantos numeros desea ingresar? " << endl; cin >> n;

for (int i = 1; i <= n; i = i + 1) {


cout << "ingrese el numero "; cin >> z;
sp = 0;
co = 1;
si = 0;
while (co != 0) {

co = z / 10;
ci = co * 10;
p = z - ci;
f = pow(2, si);
sp = sp + p*f;
z = co;
si = si + 1;
}
cout << "el numero en base 10 es " << sp << endl;

}
getch();
}
19. PARA N DATOS ENTEROS CADA UNO CON
CUALQUIER NÚMERO DE CIFRAS, BUSQUE EL
MAYOR NÚMERO Y EL MENOR; INDIQUE CUÁNTAS
CIFRAS DEL MAYOR SON PARES Y DEL MENOR DIGA
CUANTAS CIFRAS SON MÚLTIPLO DE TRES.
#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int main() {
float mayor, menor, n, x;
int co, ci, p, sp;
cout << "¿cuantos numeros desea ingresar? "; cin >> n;
mayor = -100000000000;
menor = 999999999999;

for (int i = 1; i <= n; i = i + 1) {


cout << "INGRESAR LOS NUMEROS "; cin >> x;
if (x>mayor) {

mayor = x;

}
if (x<menor) {

menor = x;

}
cout << "EL NUMERO MAYOR ES " << mayor << endl;
cout << "EL NUMERO MENOR ES " << menor << endl; int a, y, z;
y = mayor;
z = menor;
sp = 0;
co = 1;

a = 0;
while (co != 0) {

co = mayor / 10;
ci = co * 10;
p = mayor - ci;
if (p % 2 == 0) {
a = a + 1;
}
mayor = co;
}

cout << "el numero de cifras pares de " << y << " es: " << a << endl;
sp = 0;
co = 1;

a = 0;
while (co != 0) {

co = menor / 10;
ci = co * 10;
p = menor - ci;
if (p % 3 == 0) {
a = a + 1;
}
menor = co;
}
cout << "el numero de cifras pmultiplos de tres de " << z << " es: " << a <<
endl;

getch();
}

CORRECCION PARCIAL

20. -CORRECCIÓN PARCIAL POR MÉTODO CIFRAS


#include "stdafx.h"
#include "iostream"
#include<conio.h>
using namespace System;
using namespace std;

int main() {
float mayor, n, x;
int co, ci, p, sp, suma, total, a, b, dif, con, h, sumai;
cout << "¿cuantos numeros desea ingresar? " << endl; cin >> n;//ingresa
numero de vueltas
suma = 0;

for (int z = 1; z <= n; z = z + 1) {


cout << "INGRESAR LOS NUMEROS " << endl; cin >>
x; //ingresa numeros

suma = suma + x; //suma numeros


sumai = suma;
total = 0;
con = 0;

h = x;
while (x != 0) {

a = x / 2,
b = a * 2;
dif = x - b;
total = total + (dif*pow(10, con)); //halla binarios
con = con + 1;
x = a;
}
cout << "el binario de " << h << " es: " << total << endl;
}
int c, r, m, f;
c = 0;
r = suma - 1;
for (int i = 1; i <= r; i = i + 1) {
m = suma / i;
f = m*i; // halle la suma de divisores
if (suma == f) {

c = c + i;
}

if (c != suma) {

cout << "la suma de los numeros= " << sumai << " no es un numero
perfecto" << endl;

}
else
{
cout << "Ela suma de los numeros= " << sumai << " es un numero
perfecto" << endl;

getch();
}

21. CORRECCIÓN PARCIAL MÉTODO LOGARITMO


#include "stdafx.h"
#include "iostream"
#include<conio.h>

using namespace System;


using namespace std;

int main() {

int a, b, c, h, ex, rta, i, z, s, t, x, n, f, sumai, suma;


cout << "¿cuantos numeros desea ingresar? " << endl; cin >> n;

suma = 0;

for (int s = 1; s <= n; s = s + 1) {

cout << "ingrese el numero "; cin >> z;


suma = suma + z; //suma numeros
sumai = suma;

h = x;
i = 0;
rta = 0;
ex = log2(z);
a = z;
for (int b = 0; b<ex; b = b + 1) {

if (a % 2 == 1) {
c = pow(10, b);
rta = c + rta;

}
a = a / 2;
t = b + 1;
}
x = pow(10, t);
rta = rta + x;

cout << "el binario de " << z << " es:" << rta << endl;
}
int gh, r, m;
gh = 0;
r = suma - 1;
for (int i = 1; i <= r; i = i + 1) {
m = suma / i;
f = m*i; // halle la suma de divisores
if (suma == f) {

gh = gh + i;
}

}
if (gh != suma) {

cout << "la suma de los numeros= " << sumai << " no es un numero
perfecto" << endl;

}
else
{
cout << "Ela suma de los numeros= " << sumai << " es un numero
perfecto" << endl;

}
getch();
}

EJERCICIOS MULTIMEDIA
22. PRIMERA CALCULADORA CON FUNCIONES,
SUMA, RESTA, SENO COSENO

#include "stdafx.h"
#include "iostream"
#include<conio.h>

using namespace System;


using namespace std;

int linea, op;


void fijo()
{

Console::WriteLine(L"===================================calculador
a laura uis================================");
}

void limpiaopciones()
{
int i;
linea = 5;
Console::SetCursorPosition(3, linea);
for (i = 1; i <= 32; i = i + 1)
{
cout << " ";
}
Console::ForegroundColor::set(ConsoleColor::White);//letra Blanca
linea = 5;
}

void opciones()
{
Console::ForegroundColor::set(ConsoleColor::Green);//letra Verde
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"calculadora laura uis");
Console::WriteLine(L"1. smua ");
Console::WriteLine(L"2. resta ");
Console::WriteLine(L"3. factorial ");
Console::WriteLine(L"4. decir si es perfecto ");
Console::WriteLine(L"5. primo o compuesto ");
Console::WriteLine(L"6. seno");
Console::WriteLine(L"7. coseno por taylor ");
Console::WriteLine(L"8.raiz ");
Console::WriteLine(L"... otras FUNCIONES");
Console::WriteLine(L"9. para TERMINAR ");
cout << "\n\n Digite opcion ";
cin >> op;
limpiaopciones();
}

void suma()
{
float x, y, z;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" SUMA DE DOS NUMEROS ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
cout << " Digite numero x = "; cin >> x;
cout << " Digite numero y = "; cin >> y;
z = x + y;
cout << "\n\n Suma = " << z;
Console::WriteLine(L"... Enter para salir ");
getch();
}

void producto()
{
float x, y, z;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" PRODUCTO DE DOS NUMEROS ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
cout << " Digite numero x = "; cin >> x;
cout << " Digite numero y = "; cin >> y;
z = x*y;
cout << "\n\n producto = " << z;
Console::WriteLine(L"... Enter para salir ");
getch();
}

void factorial()
{
float x, y, fd;
fd = 1;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" Factorial de un numero ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
cout << " Digite numero x = "; cin >> x;
for (y = 1; y <= x; y = y + 1) {
fd = fd*y;
}
cout << "\n\n factorial = " << fd;
Console::WriteLine(L"... Enter para salir ");
getch();
}
void primo()
{
int pp, f, ci, sa, x, sp;

linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" diga si un numero es primo ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);

cout << "Ingrese el numero "; cin >> x;

f = x - 1;
for (int a = 2; a<x; a = a + 1) {
ci = x / a;

sp = ci*a;

if (sp == x) {
cout << " " << x << ", no es primo" << endl;
a = f;
sa = 0;
}
else {
sa = 1;
}
}
if (sa == 1)
{
cout << " " << x << ", es primo " << endl;

Console::WriteLine(L"... Enter para salir ");


getch();
}
void perfecto()
{

linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" diga si un numero es perfecto");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
int sc, pp, pl, f, x;
cout << "Ingrese el numero "; cin >> x;
sc = 0;
f = x - 1;
for (int i = 1; i <= f; i = i + 1) {
pp = x / i;
pl = pp*i;
if (pl == x) {

sc = sc + i;
}

if (sc != x) {

cout << "EL NUMERO " << x << " NO ES PERFECTO";

}
else
{
cout << "EL NUMERO " << x << " ES PERFECTO";

Console::WriteLine(L"... Enter para salir ");


getch();
}
void seno()
{

linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" halle el seno");
linea = linea + 1;
Console::SetCursorPosition(3, linea);

float x, a, rad, n, m, sen, cas, ton, cot, sic, csca, sent, cost;
cout << "Ingrese el angulo "; cin >> m;

rad = 3.141592*m / 180;

float sx, e, d, sig, t, s, fd;


sx = 0;
e = 1;
d = 1;
sig = 1;

for (t = 1; t <= 10; t = t + 1)


{
fd = 1;
for (s = 1; s <= d; s = s + 1) {

fd = fd * s;
}
float resultado = pow(rad, e);
sx = sx + (sig*(resultado / fd));

e = e + 2;
d = d + 2;
sig = -1 * sig;
}

cout << "el seno por taylor es igual a: " << sx << endl;

Console::WriteLine(L"... Enter para salir ");


getch();
}
void coseno()
{

linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" halle el coseno");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
float x, a, rad, n, m, sen, cas, ton, cot, sic, sent, cost;

cout << "Ingrese el angulo "; cin >> m;

rad = 3.141592*m / 180;

float sx, e, d, sig, t, s, fd;


sx = 1;
e = 2;
d = 2;
sig = -1;

for (t = 1; t <= 10; t = t + 1)


{
fd = 1;
for (s = 1; s <= d; s = s + 1) {

fd = fd * s;
}
float resultado = pow(rad, e);
sx = sx + (sig*(resultado / fd));

e = e + 2;
d = d + 2;
sig = -1 * sig;
}
cout << "el coseno por taylor es igual a: " << sx << endl;

Console::WriteLine(L"... Enter para salir ");


getch();
}
void raiz()
{

linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" halle la raiz");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
int x;
cout << "Ingrese el numero "; cin >> x;
float raiza, raizn;
raiza = 1;
for (int z = 1; z<11; z = z + 1) {
raizn = 0.5*(raiza + x / raiza);
raiza = raizn;
}
cout << "la raiz es = " << raiza;
Console::WriteLine(L"... Enter para salir ");
getch();
}
int main()
{
fijo();
do {
opciones();
switch (op)
{
case 1: { suma(); limpiaopciones(); break; }
case 2: { producto(); limpiaopciones(); break; }
case 3: { factorial(); limpiaopciones(); break; }
case 4: { perfecto(); limpiaopciones(); break; }
case 5: { primo(); limpiaopciones(); break; }
case 6: { seno(); limpiaopciones(); break; }
case 7: { coseno(); limpiaopciones(); break; }
case 8: { raiz(); limpiaopciones(); break; }
}
} while (op != 9);
cout << "Termina sistema ";
getch();
}

23. CORRECIÓN
MULTIMEDIA 1 CON LIMPIAOPCIONES,
SUMA PRODUCTO FACTORIAL
#include "stdafx.h"
#include "iostream"
#include<conio.h>
using namespace System;
using namespace std;

int linea, op;

void fijo()
{
cout << "=======================";
cout << "titulo permanente";
Console::WriteLine(L"=======================");
}

void limpiaopciones()
{
int i;
linea = 5;
Console::SetCursorPosition(3, linea);
for (i = 1; i <= 15; i = i + 1)
{
cout << " ";
}
Console::ForegroundColor::set(ConsoleColor::White);//letra Blanca
linea = 5;
}

void opciones()
{
Console::ForegroundColor::set(ConsoleColor::Green);//letra Verde
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"FUNCIONES DE HP-XXX ");
Console::WriteLine(L"1. suma ");
Console::WriteLine(L"2. producto ");
Console::WriteLine(L"3. factorial ");
Console::WriteLine(L"... otras FUNCIONES");
Console::WriteLine(L"9. para TERMINAR ");
cout << "\n\n Digite opcion ";
cin >> op;
limpiaopciones();
}

void suma()
{
float x, y, z;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" SUMA DE DOS NUMEROS ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
cout << " Digite numero x = a "; cin >> x;
cout << " Digite numero y = a "; cin >> y;
z = x + y;
cout << "\n\n Suma = a " << z;
Console::WriteLine(L"... Enter para salir ");
getch();
}
void factorial()
{
float x, y, z, fd;
fd = 1;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" factorial ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
cout << " Digite numero x = a "; cin >> x;
for (int i = 1; i <= x; i = i + 1) {
fd = fd*i;
}

cout << "Factorial " << fd;


Console::WriteLine(L"... Enter para salir ");
getch();
}

void producto()
{
float x, y, z;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" PRODUCTO DE DOS NUMEROS ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
cout << " Digite numero x = a "; cin >> x;
cout << " Digite numero y = a "; cin >> y;
z = x*y;
cout << "\n\n producto = a " << z;
Console::WriteLine(L"... Enter para salir ");
getch();
}

int main()
{
fijo();
do {
opciones();
switch (op)
{
case 1: { suma(); limpiaopciones(); break; }
case 2: { producto(); limpiaopciones(); break; }
case 3:{ factorial();limpiaopciones();break;}
}
} while (op != 9);
cout << "Termina sistema ";
getch();
}

24. MULTIMEDIA, ENLACES A LA RED FACEBOOK,


VANGUARDIA ETC (A) Y CANCIÓN,VIDEO, IMAGEN
DENTRO DEL COMPUTADOR (B)
#include "stdafx.h"
#include "iostream"
#include<conio.h>
using namespace System;
using namespace std;

int linea, op;

void fijo()
{
cout << " ==============================";
cout << "\n PROGRAMA INTERACTIVO UIS ";
cout << "\n Grupos VisualStudio C++ UIS";
cout << "\n LAURA RIOS";
cout << "\n ==============================";
}

void limpiaopciones()
{
int i;
linea = 5;
Console::SetCursorPosition(3, linea);
for (i = 1; i <= 20; i = i + 1)
{
cout << " ";
}
Console::ForegroundColor::set(ConsoleColor::White);//letra Blanca
linea = 5;
}

void opciones()
{
Console::ForegroundColor::set(ConsoleColor::Green);//letra Verde
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"APLICACIONES INGENIERIA ");
Console::WriteLine(L"1. BIBLIOTECA UIS ");
Console::WriteLine(L"2. POLITICA NOTICIAS ");
Console::WriteLine(L"3. ING MECANICA");
Console::WriteLine(L"4. ING INDUSTRIAL");
Console::WriteLine(L"5.leer vanguardia liberal");
Console::WriteLine(L"6.facebook");
Console::WriteLine(L"7. cancion");
Console::WriteLine(L"8.video");
Console::WriteLine(L"9.foto");
Console::WriteLine(L"... otras FUNCIONES");
Console::WriteLine(L"10. para TERMINAR ");
cout << "\n\n Digite opcion ";
cin >> op;
limpiaopciones();
}

void bibliotecauis()
{
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"Hola a todos VOY A BIBLIOTECA UIS === > presione
Intro y espere ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
//getch();
system("explorer http://tangara.uis.edu.co/");
Console::WriteLine(L"... Enter para salir ");
getch();
}

void politica()
{
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" NOTICIAS POLITICA === > presione Intro y espere ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
getch();
system("explorer http://goo.gl/BqaqT");
getch();
Console::WriteLine(L"Regrese de POLITICA ");
Console::WriteLine(L" Intro pata terminar y/o salirr ");
Console::WriteLine(L"... Enter para salir ");
getch();
}
void ingmecanica()
{
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" VOY A INGENIERIA MECANICA ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"CONSULTA INGENIERIA MECANICA");
Console::WriteLine(L" Conectar APLICACIÓN === > presione Intro y espere");
getch();
system("explorer https://bit.ly/2tvECI3");
getch();
Console::WriteLine(L" Ir a problemas Ingenieria Mecanica === > presione Intro y
espere ");
getch();
system("explorer https://tinyurl.com/y5wv85yf");
getch();
Console::WriteLine(L"... Enter para salir ");
getch();
}

Void ingindustrial()
{
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" ");
//linea = linea + 1;
Console::SetCursorPosition(3, linea);

Console::WriteLine(L"=============================================
========");
Console::WriteLine(L" UIS APLICACIÓNES INGENIERIA INDUSTRIAL ");
Console::WriteLine(L" Estudiantes UIS ing - industrial ");

Console::WriteLine(L"=============================================
===========================");
Console::WriteLine(L" inicia dispositivo(explorer google) y ruta donde estan las
aplicaciones");

Console::WriteLine(L"=============================================
===========================");
Console::WriteLine(L" Conectar APLICACIÓN === > presione Intro y espere ");
getch();
system("explorer https://tinyurl.com/yyax4q6z");
linea = 11;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" ");
getch();
linea = linea + 1;
Console::WriteLine(L" Ir a PROBLEMAS Ingenieria Industrial === > presione
Intro y espere");
getch();
system("explorer https://tinyurl.com/y3275xnp");
linea = 12;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" ");
Console::WriteLine(L"... intro para salir ");
getch();

}
void vanguardia()
{
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"Hola a todos VOY A vanguardia === > presione Intro y
espere ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
//getch();
system("explorer https://www.vanguardia.com/");
Console::WriteLine(L"... Enter para salir ");
getch();
}

void face()
{
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"Hola a todos VOY A facebook === > presione Intro y
espere ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
//getch();
system("explorer https://www.facebook.com/");
Console::WriteLine(L"... Enter para salir ");
getch();
}
void cancion1() {
linea = 1;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"Ejecutando");
cout << "Sonando como en el cielo";
system("start mplayer2.exe /play C:/Users/Descargas/cancion.mp3");
getch();
}

void video() {
linea = 1;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"ejecutando");
cout << "Viendo video";
system("start mplayer2.exe /play C:/Users/Descargas/video.mp4");
getch();
}

void imagen() {
linea = 1;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"ejecutando");
cout << "Viendo imagenes";
system(" C:/Users/Estudiante/Downloads/uis.png");
getch();
}

int main()
{
fijo();
do {
opciones();
switch (op)
{
case 1: { bibliotecauis(); limpiaopciones(); break; }
case 2: { politica(); limpiaopciones(); break; }
case 3: { ingmecanica(); limpiaopciones(); break; }
case 4: { ingindustrial(); limpiaopciones(); break; }
case 5: {vanguardia(); limpiaopciones(); break; }
case 6: {face(); limpiaopciones(); break; }
case 7: { cancion1(); limpiaopciones(); break; }
case 8: {video(); limpiaopciones(); break; }
case 9: {imagen(); limpiaopciones(); break; }
// espacios para mas FUNCIONES
}
} while (op != 10); // opcion = 9 Terminar
Console::WriteLine(L"Termina sistema ");
getch();
}
25. CALCULADORA CON LOS 7 EJERCICIOS TIPO
PREVIO
#include "stdafx.h"

#include "iostream"

#include <conio.h>

using namespace System;

using namespace std;

int linea, op;


int a[10][20], n, x, i, j, facj, clave, c, cp, mayork, sp[100],na,mayorz, menorz;

void fijo()
{

cout << " ==============================";

cout << "\n PROGRAMAS TIPO PREVIO ";

cout << "\n Grupos VisualStudio C++ UIS";

cout << "\n PROF Leonel Parra Pinilla ";

cout << "\n ==============================";


getch();

void limpiaopciones()

int i;

linea = 5;

Console::SetCursorPosition(3, linea);

for (i = 1; i <= 40; i = i + 1)


{

cout << " ";

Console::ForegroundColor::set(ConsoleColor::White);//letra Blanca

linea = 9;

void opciones()

Console::ForegroundColor::set(ConsoleColor::Green);//letra Verde

linea = 5;

Console::SetCursorPosition(3, linea);

Console::WriteLine(L"PROBLEMAS TIPO PREVIO ");

Console::WriteLine(L"1. funciones trigonometricas");

Console::WriteLine(L"2. primo mayo a binario ");

Console::WriteLine(L"3. repetida");

Console::WriteLine(L"4. base10 ordenar");

Console::WriteLine(L"5. mayor menor contar");

Console::WriteLine(L"6. ejercicio 6");


Console::WriteLine(L"7. hacer matriz");

Console::WriteLine(L"8 para terminar");

cout << "\n\n Digite opcion ";

cin >> op;

limpiaopciones();

}
void suma() // si j es primo
{
float mayor, n, x, menor;
int co, ci, p, sp, z;

menor = 999999;

sp = 0;
co = 1;
while (co != 0) {

co = z / 10,
ci = co * 10;
p = z - ci;
sp = sp + p;
z = co;
}
cout << "la suma de sus cifras es " << sp << endl;
if (sp < menor) {

menor = sp;

}
}

void repetida()
{

linea = 7;
Console::SetCursorPosition(3, linea);

linea = linea + 2;
Console::SetCursorPosition(3, linea);
float mayor, n, x, menor;
int co, ci, p, sp, a, b, c, d, e, f, g, h, i, j, s, z, za;

cout << "Teclee numero de datos = a "; cin >> za;


menor = 99999999999;
for (int s = 1; s <= za; s = s + 1) {
cout << "ingrese el numero "; cin >> z;
sp = 0;
co = 1;
a = 0; /*0*/
b = 0; /*1*/
c = 0; /*2*/
d = 0; /*3*/
e = 0; /*4*/
f = 0; /*5*/
g = 0; /*6*/
h = 0; /*7*/
i = 0; /*8*/
j = 0; /*9*/
x = z;
while (co != 0) {

co = x / 10,
ci = co * 10;
p = x - ci;
x = co;
if (p == 0) {
a = a + 1;
}
if (p == 1) {
b = b + 1;
}if (p == 2) {
c = c + 1;
}if (p == 3) {
d = d + 1;
}if (p == 4) {
e = e + 1;
}if (p == 5) {
f = f + 1;
}if (p == 6) {
g = g + 1;
}if (p == 7) {
h = h + 1;
}
if (p == 8) {
i = i + 1;
}
if (p == 9) {
j = j + 1;
}

}
if (a >= b&&a >= c&&a >= d&&a >= e&&a >= f&&a >= g&&a >= h&&a
>= i&&a >= j&&a != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 0 " << endl;
}
if (b >= a&&b >= c&&b >= d&&b >= e&&b >= f&&b >= g&&b >= h&&b
>= i&&b >= j&&b != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 1 " << endl;
}
if (c >= b&&c >= a&&c >= d&&c >= e&&c >= f&&c >= g&&c >= h&&c
>= i&&c >= j&&c != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 2 " << endl;
}
if (d >= b&&d >= c&&d >= a&&d >= e&&d >= f&&d >= g&&d >= h&&d
>= i&&d >= j&&d != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 3 " << endl;
}
if (e >= b&&e >= c&&e >= d&&e >= a&&e >= f&&e >= g&&e >= h&&e
>= i&&e >= j&&e != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 4 " << endl;
}
if (f >= b&&f >= c&&f >= d&&f >= e&&f >= a&&f >= g&&f >= h&&f >=
i&&f >= j&&f != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 5" << endl;
}
if (g >= b&&g >= c&&g >= d&&g >= e&&g >= f&&g >= a&&g >= h&&g
>= i&&g >= j&&g != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 6 " << endl;
}
if (h >= b&&h >= c&&h >= d&&h >= e&&h >= f&&h >= g&&h >= a&&h
>= i&&h >= j&&h != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 7 " << endl;
}
if (i >= b&&i >= c&&i >= d&&i >= e&&i >= f&&i >= g&&i >= h&&i >=
a&&i >= j&&i != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 8 " << endl;
}
if (j >= b&&j >= c&&j >= d&&j >= e&&j >= f&&j >= g&&j >= h&&j >=
i&&j >= a&&j != 0)
{
cout << "la cifra mas repetida de " << z << " es: " << " 9 " << endl;
}

sp = 0;
co = 1;
while (co != 0) {

co = z / 10,
ci = co * 10;
p = z - ci;
sp = sp + p;
z = co;
}
cout << "la suma de sus cifras es " << sp << endl;
if (sp < menor) {

menor = sp;

}
}

cout << "LA SUMA DE CIFRAS MENOR ES " << menor << endl;

getch();
}

void tercero() // si j es primo


{
int n, menor, z;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" cifra repetida ");
linea = linea + 1;
Console::SetCursorPosition(4, linea);

repetida(); // usar funcion primo() para saber si el j es primo

// como j fue primo entonces calcular su factorial

getch();
cout << "\n\n";

}
void ordene() {

linea = 20;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" de binario a base diez y ordenarlo ");
linea = linea + 1;
Console::SetCursorPosition(4, linea);
int aux;
for (int i = 1; i < na; i = i + 1)
{
for (int j = i + 1; j < na; j = j + 1) {

if (sp[i] > sp[j]) {


aux = sp[i];
sp[i] = sp[j];
sp[j] = aux;
}
}
}
cout << "los datos ordenados de menor a mayor son";
for (i = 0; i <= na; i = i + 1) {
cout << sp[i] << endl;
}
getch();
}
void base10() {

int a, b, c, h, ex, rta, i, z, s, t, x, n, f, co, si , ci, p;


linea = 7;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" de binario a base diez y ordenarlo ");
linea = linea + 1;
Console::SetCursorPosition(4, linea);
cout << "żcuantos numeros desea ingresar? " << endl; cin >> na;

for (int i = 1; i <= na; i = i + 1) {


cout << "ingrese el numero "; cin >> z;
sp[i] = 0;
co = 1;
si = 0;
while (co != 0) {

co = z / 10;
ci = co * 10;
p = z - ci;
f = pow(2, si);
sp[i] = sp[i] + p*f;
z = co;
si = si + 1;
}
cout << "el numero en base 10 es " << sp[i] << endl;

}
ordene();
getch();
}

void parsa() {
int a, b, c, h, ex, rta, i, z, s, t, x, n, f, za;

linea = 15;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" binario del mayor");
linea = linea + 1;
Console::SetCursorPosition(4, linea);
z = mayork;
i = 0;
rta = 0;
ex = log2(z);
a = z;
for (int b = 0; b<ex; b = b + 1) {

if (a % 2 == 1) {
c = pow(10, b);
rta = c + rta;

}
a = a / 2;
t = b + 1;
}
x = pow(10, t);
rta = rta + x;

cout << "el binario de " << z << " es:" << rta << endl;

void primo2() {
float mayor, n, x;
int co, f, ci, p, sp, sa;

mayork = 0;
linea = 7;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" binario ");
linea = linea + 1;
Console::SetCursorPosition(4, linea);
cout << "żcuantos numeros desea ingresar? "; cin >> n;

for (int i = 1; i<n + 1; i = i + 1) {


cout << "INGRESAR LOS NUMEROS "; cin >> x;

f = x - 1;
for (int a = 2; a<x; a = a + 1) {
ci = x / a;
sp = ci*a;

if (sp == x) {
cout << " " << x << ", no es primo" << endl;
a = f;
sa = 0;
}
else {
sa = 1;
}
}
if (sa == 1)
{
cout << " " << x << ", es primo " << endl;

if (x>mayork) {

mayork = x;

}
}

}
cout << "el mayor de los primos es: " << mayork;
parsa();
getch();

void primo() // si j es primo

int fin, k, co, pr;

clave = 1;

fin = j - 1;

for (k = 2; k <= fin; k = k + 1)

co = int(j / k);
pr = co*k;

if (pr == j)

clave = 0;

k = fin; // para abandonar la repeticion porque j no es primo

} // fin del for k para divisiones saber si j es divisible o no

}
void hacermatriz()
{

int a[6][6], ma[100], m[100], ii, jj, c1, c2, k, x;

Console::ForegroundColor::set(ConsoleColor::Green);//letra Verde

linea = 8;

Console::SetCursorPosition(3, linea);

Console::Write(L"cuantas edades n = a ");

cin >> n;// n = 5 pej: 50 15 70 10 35

// leo cada edad y se acomoda en vector ma las mayores que 20


// y las menores que 20 en el vector m como dice el enunciado
// y las cuento cuantas hay

c1 = 0; // contador mayores de 20
c2 = 0; // contador menores que 20
for (ii = 1; ii <= n; ii = ii + 1)
// iniciar proceso entrar datos
{
cout << " tecle dato " << ii << " = ";
cin >> x;
if (x >= 20)
{
c1 = c1 + 1;
ma[c1] = x; // cada x mayor que 20 y se cuentan
}
else {
c2 = c2 + 1;
m[c2] = x; // cada x menor que 20 va a vector m y se cuentan
}
}

// proceso llenar la matriz a de 6x6 con edad 22 dice el enunciado

for (ii = 1; ii <= 6; ii = ii + 1) // hacer matiz de 6*6 con el 22

for (jj = 1; jj <= 6; jj = jj + 1) // es de n x 20 columnas

a[ii][jj] = 22;

// proceso para pasar los c1 mayores que 20 a la matriz a de 6x6

k = 1; // para pasar de uno en uno los c1 mayores de 20 a la matriz

for (ii = 1; ii <= 6; ii = ii + 1) // trabajar cada numero de los c1 numeros

{
for (jj = 1; jj <= 6; jj = jj + 1) // es de n x 20 columnas

{
if (k <= c1) // para colocar todos los mayores que 20 en a de 6*6

{
a[ii][jj] = ma[k];
k = k + 1;
}

else { // no hay mas para colocar en a de 6x6


ii = 6;
jj = 6;
}

}// cierre for jj


} // cierre de for ii de hacer la matriz

// imprimir vector m con los menores de 20 anos


cout << "\n el vector de menores m es " << endl;
for (ii = 1; ii <= c2; ii = ii + 1) // m tiene c2 menores de 20
{
cout << m[ii] << " ";
}

// imprimir la matriz a de 6x6


cout << "\n la matriz de 6 x 6 es " << endl;
for (ii = 1; ii <= 6; ii = ii + 1) // hacer matiz de 6*6 con el 22

for (jj = 1; jj <= 6; jj = jj + 1) // es de n x 20 columnas

{
cout << a[ii][jj] << " ";

}
cout << "\n";
}

void factorial() // Calculo del factorial de cada numero j que fue primo

int ii;

facj = 1;

for (ii = 1; ii <= j; ii = ii + 1)

facj = facj*ii;

} // fin del void factorial


void funciones()
{

Console::SetCursorPosition(3, linea);

Console::WriteLine(L"Teclee n = a ");

cin >> n;// n = 2; // para la prueba; el 16 y el 12 del ejemplo

for (i = 1; i <= n; i = i + 1)

for (j = 1; j <= 20; j = j + 1) // es de n x 20 columnas

a[i][j] = 0;

// iniciar proceso entrar datos


limpiaopciones();

for (i = 1; i <= n; i = i + 1)

{
Console::SetCursorPosition(3, linea);
linea = linea + 1;

cout << " tecle dato " << i << " = ";

cin >> x;

a[i][1] = x; // colocar cada dato en la columna 1

}
for (i = 1; i <= n; i = i + 1) // trabajar cada numero de los n numeroso

x = a[i][1]; // el respetivo numero

c = 2; // para colocar a partir de columna 2 de cada fila primos que haya


entre 3 y el respectivo numero

cp = 0; // contar cuántos primos hay

for (j = 3; j <= x; j = j + 1) //sacar los primos entre 3 y el respectivo numero


(osea si j es primo)

primo(); // usar funcion primo() para saber si el j es primo

if (clave == 1) // clave = 1 è es primo ==> se cuenta

cp = cp + 1; // se cuentan los primos que haya entre 3 y el


numero

// como j fue primo entonces calcular


su factorial

factorial();

a[i][c] = facj; //se coloca el factorial del primo j en respectiva


columna de la fila a partir de la 2

c = c + 1; // si otro primo ==> su factorial ubicarlo en la


siguiente columna

} // fin del for j para mirar si el otro j de entre 3 y el numero es o no es primo

a[i][20] = cp; // como ya se analizaron los j =è colocar en la columna 20 de


la fila cuantos primos hubo

} // fin del for i mirar el otro numero para el ejemplo 2 numeros

// Imprimir la matriz resultante a de n x 20


for (i = 1; i <= n; i = i + 1)

for (j = 1; j <= 20; j = j + 1)

if (a[i][j] > 0)

cout << a[i][j] << " ";

getch();

cout << "\n\n";

cout << " termina VOID FUNCIONES ";


limpiaopciones();
getch();

void trigo()
{

linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L" seno cos tan cot ");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
float x, a, rad, n, m, sen, cas, ton, cot, sic, csca, sent, cost;

cout << "ingrese el numero de angulos a hallar su razones trigonometricas ";


cin >> n;

for (int i = 1; i <= n; i = i + 1) {


cout << "ingrese el valor del angulo" << endl;
cin >> m;
rad = 3.141592*m / 180;
sen = sin(rad);
cout << "el seno es igual a: " << sen << endl;
cas = cos(rad);
cout << "el coseno es igual a: " << cas << endl;

if (cas == 0) {
cout << "tangente tiende a infinito" << endl;
cout << "secante tiende a infinito" << endl;
}
else {
ton = sen / cas;
cout << "tangente es igual a: " << ton << endl;
sic = 1 / cas;
cout << "secante es igual a: " << sic << endl;
}
if (sen == 0) {
cout << "cotangente tiende a infinito" << endl;
cout << "cosecante tiende a infinito" << endl;
}
else {
cot = cas / sen;
cout << "cotangente es igual a: " << cot << endl;
csca = 1 / sen;
cout << "cosecante es igual a: " << csca << endl;
}
float sx, e, d, sig, t, s, fd;
sx = 0;
e = 1;
d = 1;
sig = 1;

for (t = 1; t <= 10; t = t + 1)


{
fd = 1;
for (s = 1; s <= d; s = s + 1) {

fd = fd * s;
}
float resultado = pow(rad, e);
sx = sx + (sig*(resultado / fd));

e = e + 2;
d = d + 2;
sig = -1 * sig;
}
cout << "el seno por taylor es igual a: " << sx << endl;
sx = 1;
e = 2;
d = 2;
sig = -1;

for (t = 1; t <= 10; t = t + 1)


{
fd = 1;
for (s = 1; s <= d; s = s + 1) {

fd = fd * s;
}
float resultado = pow(rad, e);
sx = sx + (sig*(resultado / fd));

e = e + 2;
d = d + 2;
sig = -1 * sig;
}
cout << "el coseno por taylor es igual a: " << sx << endl;
}
getch();
}
void contar() {
linea = 15;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"pares del mayor, multiplos de tres del menor");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
int co, ci, p, sp, a, z, y;
sp = 0;
co = 1;
a = 0;
z = mayorz;
y = menorz;
while (co != 0) {

co = mayorz / 10,
ci = co * 10;
p = mayorz - ci;
if (p % 2 == 0)
{
a = a + 1;
}
mayorz = co;
}
cout << "el numero de cifras pares es de " << z << " es: " << a << endl;
sp = 0;
co = 1;
a = 0;
while (co != 0) {

co = menorz / 10,
ci = co * 10;
p = menorz - ci;
if (p % 3 == 0)
{
a = a + 1;
}
menorz = co;
}
cout << "el numero de cifras multiplos de 3 de " << y << " es: " << a << endl;
}

void mayorm() {
float mayor, n, x, menor;
int co, ci, p, a, z, y;
linea = 5;
Console::SetCursorPosition(3, linea);
Console::WriteLine(L"hallar el mayor y el menor decir cuantas cifras con pares o
multiplos de tres");
linea = linea + 1;
Console::SetCursorPosition(3, linea);
cout << "¿cuantos numeros desea ingresar? "; cin >> n;
mayorz = -1000000000;
menorz = 999999999;
for (int i = 1; i <= n; i = i + 1) {
cout << "INGRESAR LOS NUMEROS "; cin >> x;
if (x>mayorz) {

mayorz = x;

}
if (x<menorz) {

menorz = x;
}

}
cout << "EL NUMERO MAYOR ES " << mayorz << endl;
cout << "EL NUMERO MENOR ES " << menorz << endl;
contar();
getch();
}

int main()

{
fijo();
do {

opciones();

switch (op)

case 1: { trigo(); limpiaopciones(); break; }

case 2: { primo2(); limpiaopciones(); break; }

case 3: {tercero(); limpiaopciones(); break; }

case 4: { base10(); limpiaopciones(); break; }

case 5: { mayorm(); limpiaopciones(); break; }

case 6: { funciones(); limpiaopciones(); break; }

case 7: { hacermatriz(); limpiaopciones(); break; }

} while (op != 8); // opcion = 8 Terminar

Console::WriteLine(L"Termina sistema ");

getch();
}

También podría gustarte