Está en la página 1de 5

1.

/*Disee un programa que ingrese n numeros enteros a un arreglo lineal. Luego se p


ide calcular e imprimir:
a) El numero mas alto
b) El promedio de los numeros
c) La cantidad de cifras de cada numero
APLIQUE SUBPROGRAMAS CON PASO DE PARAMETROS */
#include<iostream>
#include<conio.h>
#include<stdlib.h>
void cantidad(int *xn);
void recarga_arreglo(int xnum[],int xn);
int maximo(int xnum[],int xn);
void cant_cifras(int xnum[],int xn);
float promedio(int xnum[],int xn);
void main()
{
system("color f5");
int n,num[100];
cantidad(&n);
recarga_arreglo(num,n);
cout<<"El numero maximo es: "<<maximo(num,n)<<endl;
cout<<"El promedio es: "<<promedio(num,n)<<endl;
cant_cifras(num,n);
getch();
}
void cantidad(int *xn)
{
do
{
cout<<"Ingrese el tamanio del arreglo: ";
cin>>*xn;
}
while(*xn>100);
cout<<endl;
}
void recarga_arreglo(int xnum[],int xn)
{
cout<<"RECARGA..ARREGLO"<<endl;
cout<<endl;
for(int i=0;i<xn;i++)
{
cout<<"Ingrese numero "<<i+1<<": ";
cin>>xnum[i];
}
cout<<endl;
}
float promedio(int xnum[],int xn)
{
int sum=0;
for(int i=0;i<xn;i++)
{
sum=sum+xnum[i];

}
return (1.0*sum)/xn;
}
int maximo(int xnum[],int xn)
{
int xmax=0;
for(int i=0;i<xn;i++)
{
if(xnum[i]>xmax)
xmax=xnum[i];
}
return xmax;
}
void cant_cifras(int xnum[],int xn)
{
int c,aux;
for(int i=0;i<xn;i++)
{
c=0;
aux=xnum[i];
while(xnum[i]!=0)
{
c++;
xnum[i]=xnum[i]/10;
}
cout<<"La cantidad de cifras de "<<aux<<" es: "<<c<<endl;
}
}
2.
/*Disear un programa que ingrese a un arreglo lineal las ventas mensuales que un
trabajador ha realizado
durante 3 aos. Se pide calcular e imprimir el promedio de las ventas de cada se
mestre.
Aplique subprograma con paso de parametros.*/
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void recarga_vector(float v[]);
void promedio(float v[]);
void main()
{
system("color f5");
float ventas[36];
recarga_vector(ventas);
promedio(ventas);
getch();
}
void recarga_vector(float v[])
{
for(int i=1;i<=36;i++)
{
cout<<"Venta de mes "<<i<<": ";

cin>>v[i];
}
}
void promedio(float v[])
{
float sum=0;
float prom;
for(int i=1;i<=36;i++)
{
sum+=v[i];
if(i%6==0)
{
prom=sum/6;
cout<<"El promedio del semestre "<<i/6<<" es: "<<prom<<endl;
sum=0;
}
}
}

3.

/* Realizar un programa que ingrese a un arreglo lineal numeros enteros mayores


de 3 cifras. Se pide calcular e imprimir :
a) La cantidad de numeros capicuas del arreglo
b) La cantidad de numeros cuya cifra central sea par
APLIQUE SUBPROGRAMAS CON PASO DE PARAMETROS */
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void
void
void
void

tamanio(int *xn);
recarga_arreglo(int v[],int xn);
capicua(int v[],int xn);
cifra_par(int v[],int xn);

void main()
{
system("color f5");
int n,arreglo[100],arreglo_aux[100];
tamanio(&n);
recarga_arreglo(arreglo,n);
capicua(arreglo,n);
cifra_par(arreglo,n);
getch();
}
void tamanio(int *xn)
{
do
{
cout<<"Ingrese el tamanio del arreglo: ";
cin>>*xn;
}
while(*xn>100);

cout<<endl;
}
void recarga_arreglo(int v[],int xn)
{
cout<<"INGRESE NUMEROS MAYORES DE 3 CIFRAS: "<<endl;
cout<<endl;
for(int i=1;i<=xn;i++)
{
do
{
cout<<"Ingrese numero "<<i<<": ";
cin>>v[i];
}
while(v[i]<1000);
}
}
void capicua(int v[],int xn)
{
int aux,num2,ct=0;
for(int i=1;i<=xn;i++)
{
aux=v[i];
num2=0;
while(aux!=0)
{
num2=num2*10 + aux%10;
aux=aux/10;
}
if(v[i]==num2)
{
ct++;
}
}
cout<<endl;
cout<<"La cantidad de numeros capicuas del arreglo es: "<<ct<<endl;
}
//La cantidad de numeros cuya cifra central sea par
void cifra_par(int v[],int xn)
{
int aux,ct=0,cc,cc2,pos,ci;
for(int i=1;i<=xn;i++)
{
cc=0;
cc2=0;
ci=0;
aux=v[i];
while(aux!=0)
{
cc++;
aux=aux/10;
}
aux=v[i];
if(cc%2!=0)
{
pos=(cc+1)/2;
while(aux!=0)

{
cc2++;
ci=aux%10;
if(cc2==pos)
{
if(ci%2==0 && ci!=0)
ct++;
}
aux=aux/10;
}
}
}
cout<<"La cantidad de numeros cuya cifra central es par es: "<<ct<<endl;
}

TAREA INDIVIDUAL:
DISEE UN PROGRAMA QUE INGRESE N NUMEROS ENTEROS MAYORES DE 3 CIFRAS.QUE CALCULE E
IMPRIMA:
A) EL PROMEDIO DE LAS CIFRAS DE AQUELLOS NUMEROS UBICADOS EN POSICION
........................<<FALTA>>......................
SE DESEA ALMACENAR LAS EDADES DE LOS ALUMNOS DEL CURSO DE ALGORITMOS Y ESTRUCTUR
A DE DATOS EN UN ARREGLO LINEAL ALFA Y EN OTRO ARREGLO LINEAL
EL SEXO DE CADA ALUMNO EN UN ORDEN CORRESPONDIENTE AL ANTERIOR ARREGLO. SE PIDE
CALCULAR E IMPRIMIR:
A) LA EDAD MAS ALTA Y MAS BAJA DE LAS EDADES
B) EL PROMEDIO DE LAS EDADES DE LOS HOMBRES Y LAS MUJERES
C) LA EDAD MAS ALTA DE LOS HOMBRES
D) CANTIDAD DE MUJERES QUE TENGAN EDAD DE 18 A 20 AOS
APLIQUE SUBPROGRAMA CON PASO DE PARAMETRO
NOTA: PRESENTAR EL TRABAJO EL DIA MIERCOLES 21 A CUALQUIER HORA AL CORREO. EN CA
DA PROGRAMA DEBERA IR SU CODIGO, APELLIDOS Y NOMBRES.

También podría gustarte