Sie sind auf Seite 1von 8

IIPRACTICA DEL CURSO DE ALGORITMOS

CUADRA

JOAQUIN

Ejer_1.- Disear un algoritmo para calcular el rea de un hexgono


regular inscrito en una circunferencia
ALGORITMO
Algoritmo AREA_HEXAGONO
VAR
REAL R
INICIO
LEER RADIO
R = 2*R*R*1.73 ;
IMPRIMIR R
FIN

PROGRAMA EN C++
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double opcion;
double
r ;
std::cout << "Ingrese EL radio de la Circunsferencia ? \n";
cin >> opcion;
r=(opcion*opcion*1.73)/2*8;
std::cout << "El area del hexgono es: " << r <<endl;
}

Ejer_2.- Disee un pseudocdigo para invertir un nmero de cinco cifras


(25834 43852).

ALGORITMO
Algoritmo INVERTIR_1
CONSTANTES
VAR
NUMERO , RESTO , RESPUESTA , NUMERO , INVERTIDO
INICIO
LEER NUMERO
MIENTRAS NUEMRO > 0
RESTO = NUMERO % 10
NUMERO = NUMERO / 10
INVERTIDO = INVERTIDO * 10 + RESTO
FIN
IMPRIMIR INVERTIDO
FIN

PROGRAMA EN C++
#include <iostream>
using namespace std;
int InvertirNum(int numinv)
{
int Invertido=0, Resto;
while(numinv!=0)
{
Resto=numinv%10;
numinv=numinv/10;
Invertido=Invertido*10+Resto;
}
return Invertido;
}
int main()
{
int numinv,Respuesta;
std::cout << "Ingrese el Numero a Invertir ? \n";
cin >> numinv;
Respuesta=InvertirNum(numinv);
std::cout << "El nuevo numero es : " << Respuesta
<<endl;
getwchar();
}

Ejer 3 Escribe un pseudocdigo para ordenar de mayor a menor 3 nmeros


ingresados desde el teclado.

ALGORITMO
Algoritmo ORDENAR_1
CONSTANTES
VAR
INT A,B,C TEMPORAL
INICIO
LEER NUMERO (A,B,C)
if(a<b)
{
temporal=a;
a=b;
b=temporal;
}
if(a<c)
{
temporal=a;
a=c;
c=temporal;
}

if(b<c)
{
temporal=b;
b=c;
c=temporal;
IMPRIMIR INVERTIDO
FIN

PROGRAMA EN C++
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a,b,c,temporal;
cout<<"ingrese los tres numeros enteros :"<<endl;
cin>>a;
cout<<"el segundo :";
cin>>b;
cout<<"el tercero :";
cin>>c;
if(a<b)
{
temporal=a;
a=b;
b=temporal;
}
if(a<c)
{
temporal=a;
a=c;
c=temporal;
}
if(b<c)
{
temporal=b;
b=c;
c=temporal;
}
cout<<"los numeros ordenados son :";
cout<<a<<" , "<<b<<" , "<<c<<endl;
}

Ejer 4.- Disee un pseudocdigo para resolver una ecuacin cuadrtica


(ax2 + bx + c = 0), donde Discriminante= b2 4ac.
ALGORITMO
Algoritmo CONVERTIR_EXP_1
CONSTANTES
VAR
REAL RESULTADO
INT
A ,B , C
INICIO
LEER (A,B,C)
RESULTADO = B*B 4AC
IMPRIMIR RESULTADO
FIN

PROGRAMA EN C++
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int opcionrpta;
int opcion1;
int opcion2;
int opcion3;
double
resultado1 ;
std::cout << "Ingrese el Valor para A ? \n";
cin >> opcion1;
std::cout << "Ingrese el Valor para B ? \n";
cin >> opcion2;
std::cout << "Ingrese el Valor para C ? \n";
cin >> opcion3;
std::cout << "Formula de la Ecuacion Cuadratica - b*b - 4ac

\n" ;

resultado1 = opcion2*opcion2-4*(opcion1*opcion3);
std::cout << "El resultado
<<endl;
getwchar();
return 0;
}

la primera ecuacion es

: " << resultado1

Ejer_5.- Escribir un pseudocdigo que permita ingresar un nmero


entero que representa una determinada cantidad de dinero e imprima
la cantidad de billetes de 100, 50, 20, 10, 5 y 1 soles que se
necesitan.
ALGORITMO
Algoritmo DE_NUMEROS_HORAS
CONSTANTES
VAR
INT NUM, N_200,N_100,N_50,N_20,N_10,M_5,M_2,M_1,RESTO
INICIO
LEER (NUM)
n_200 = num/200;
Resto = num%200;
n_100 = (num%200)/100;
Resto (num%200)%100;
n_50 = ((num%200)%100)/50;
Resto ((num%200)%100)%50 ;
n_20 = (((num%200)%100)%50)/20;
Resto (((num%200)%100)%50)%20
n_10 = ((((num%200)%100)%50)%20)/10;
Resto (((num%200)%100)%50)%10
m_5 = ((((num%200)%100)%50)%20)/5;
Resto=(((num%200)%100)%50)%5
m_2 = ((((num%200)%100)%50)%5)/2;
Resto (((num%200)%100)%50)%2
m_1 = ((((num%200)%100)%50)%2)/1;
IMPRIMIR N_200,N_100,N_50,N_20,N_10,M_5,M_2,M_1
FIN

PROGRAMA EN C++
#include <iostream>
using namespace std;
int main()
{
int num;
double n_200,n_100,n_50,n_20,n_10,m_5,m_2,m_1;
std::cout << "Ingrese el numero de Dinero \n";
cin >> num;
n_200 = num/200;
std::cout << "Se tiene Tantos Billetes de 200 "<< n_200 << " Resto " <<
num%200 <<endl;
n_100 = (num%200)/100;
std::cout << "Se tiene Tantos Billetes de 100 "<< n_100 << " Resto " <<
(num%200)%100 <<endl;
n_50 = ((num%200)%100)/50;
std::cout << "Se tiene Tantos Billetes de 50 "<< n_50 << " Resto " <<
((num%200)%100)%50 <<endl;
n_20 = (((num%200)%100)%50)/20;
std::cout << "Se tiene Tantos Billetes de 20 "<< n_20 << " Resto " <<
(((num%200)%100)%50)%20 <<endl;

n_10 = ((((num%200)%100)%50)%20)/10;
std::cout << "Se tiene Tantos Billetes de 10 "<< n_10 << " Resto " <<
(((num%200)%100)%50)%10 <<endl;
m_5 = ((((num%200)%100)%50)%20)/5;
std::cout << "Se tiene Tantos Monedas de 5 "<< m_5 << " Resto " <<
(((num%200)%100)%50)%5 <<endl;
m_2 = ((((num%200)%100)%50)%5)/2;
std::cout << "Se tiene Tantos Monedas de 2 "<< m_2 << " Resto " <<
(((num%200)%100)%50)%2 <<endl;
m_1 = ((((num%200)%100)%50)%2)/1;
std::cout << "Se tiene Tantos Monedas de 1 "<< m_1 <<endl;
}

Ejer_6.- Escribir un pseudocdigo que permita ingresar una determinada


hora expresada en horas, minutos y segundos, e imprima la nueva hora
despus de 30 segundos.

ALGORITMO
Algoritmo DE_NUMEROS_HORAS
CONSTANTES
VAR
INT HORA , MINUTO , SEGUNDO , TIEMPO_EN_SEGUNDOS
INICIO
LEER (HORA , MINUTO , SEGUNDO)
TIEMPO_EN_SEGUNDOS = HORA*3600 + MINUTO*60 + SEGUNDO + 30;
HORAS = FLOOR($TIEMPO_EN_SEGUNDOS / 3600);
MINUTOS = FLOOR((TIEMPO_EN_SEGUNDOS - (HORAS * 3600)) / 60);
SEGUNDOS = TIEMPO_EN_SEGUNDOS - (HORAS * 3600) - (MINUTOS * 60);
IMPRIMIR HORA , MINUTO , SEGUNDO
FIN

PROGRAMA EN C++
#include <iostream>
#include <time.h>
#include <cmath>
using namespace std;
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
hora = floor(tparcial / 3600);
minuto = floor((tparcial - (opcion1 * 3600)) / 60);
segundo = tparcial - (opcion1 * 3600) - (opcion2 * 60) + 30 ;
int main()
{
int opcionrpta; hora = floor(tparcial / 3600);
minuto = floor((tparcial - (opcion1 * 3600)) / 60);

segundo = tparcial - (opcion1 * 3600) - (opcion2 * 60) + 30 ;


int opcion1;
int opcion2;
int opcion3;
double
tparcial,hora,minuto,segundo ;
std::cout << "Ingrese
cin >> opcion1;

la Hora ? \n";

std::cout << "Ingrese el Minuto ? \n";


cin >> opcion2;
std::cout << "Ingrese los Segundos ? \n";
cin >> opcion3;
tparcial=(opcion1*3600)+(opcion2*60)+opcion3+30;
sleep(30000);
hora=(int)(tparcial / 3600);
minuto=(int)((tparcial - hora * 3600) / 60);
segundo=tparcial - (hora * 3600 + minuto * 60);
std::cout << "El resultado la primera ecuacion es : Horas => " <<
hora << " Minutos => " << minuto << " Segundos => " << segundo <<endl;
getwchar();
return 0;
}

Ejer_7.- Elabore un pseudocdigo para calcular la suma del primer


dgito y el ltimo dgito de un nmero N natural de 4 cifras

ALGORITMO
Algoritmo PRIMERO_ULTIMO
CONSTANTES
VAR
INT NUMERO
INICIO
LEER (NUMERO)
L = LONGITUD(NUMERO)
HACER MIENTRAS
RESTO (NUMERO);
IF NUMERO > 0
CAPTURO (PRIMER DIGITO)
ELSE CAPTURO (ULTIMO NUMERO)
IMPRIMIR PRIMER , ULTIMO NUMERO
FIN

PROGRAMA EN C++
#include <iostream>
using namespace std;
int contarnumeros(int numinv)
{
int contador=1;
while(numinv/10>0)
{
numinv=numinv/10;

contador++;
}
return contador;
}
int main()
{
int Invertido=0, Resto,totdig,numinv,ultimo,primero,contador2=0;
std::cout << "Ingrese el Numero a identificar el Ultimo y Primer
numero ? \n";
cin >> numinv;
totdig=contarnumeros(numinv);
while(numinv!=0)
{
Resto=numinv%10;
ultimo=Resto;
if (contador2 == 0)
{
primero = Resto;
}
numinv=numinv/10;
Invertido=Invertido*10+Resto;
contador2++;
}
std::cout << "El Primer numero fue : " << ultimo <<endl;
std::cout << "El Ultimo numero fue : " << primero <<endl;
getwchar();
}

Das könnte Ihnen auch gefallen