Está en la página 1de 27

PROBLEMA #1 PROGRAMA

PROBLEMA #1 CODIGO C++


#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
void generar_valores(int a[14]);
void emax(int a[14], int & mayor, int & pos);
void emin(int a[14],int & menor,int & pos1);
void desplegar_datos(int a[14]);
int main()
{
int i,pos,pos1;
int valores[14],mayor,menor;
generar_valores(valores);
desplegar_datos(valores);
emax(valores,mayor,pos);
emin(valores,menor,pos1);
cout<<" "<<endl;
cout<<"El dato MAYOR es "<<mayor<<" "<<endl;
cout<<"Este es el numero "<<pos<<" en la lista de numeros"<<endl;
cout<<" "<<endl;
cout<<"El dato MENOR es "<<menor<<" "<<endl;
cout<<"Este es el numero "<<pos1<<" en la lsita de numeros"<<endl;
getch();
return 0;
}
void generar_valores(int a[14])
{
int i;
srand(time(NULL));
cout<<" "<<endl;
for(i=0;i<14;i++)
{
a[i]=rand()/ 1000 +1 ;
}
}
void emax(int a[14], int & mayor, int & pos)
{
int i;
mayor=a[0];
pos=0+1;
for(i=1;i<14;i++)
{
if(a[i]>mayor)
{
mayor=a[i];
pos=i+1;
}
}
}
void emin(int a[14],int & menor,int & pos1)
{
int i;
menor=a[0];
pos1=0+1;
for(i=1;i<14;i++)
{
if(a[i]<menor)
{
menor=a[i];
pos1=i+1;
}
}
}
void desplegar_datos(int a[14])
{
int i;
cout<<"Lista de valores\n";
cout<<" "<<endl;
for(i=0;i<14;i++)
{
cout<<(i+1)<<" "<<a[i]<<endl;
}
}




PROBLEMA #1 DIAGRAMA DE FLUJO

























PROBLEMA #2 PROGRAMA

























PROBLEMA #2 CODIGO C++
#include <iostream.h>
#include <conio.h>
#include <math.h>
void Leer_Datos (int Ca[10]);
int Suma_Total (int Ca[10]);
void Desviacion (int Ca[10], double Prom, double De[10]);
void Variancia (double De[10]);
int main ()
{
int Cal[10];
double Des[10], Prome;
Leer_Datos (Cal);
cout<<"\n\n Total: "<<Suma_Total (Cal)<<endl;
Prome=(Suma_Total(Cal))/10.0;
cout<<" Promedio: "<<Prome;
getch ();
clrscr ();
Desviacion (Cal, Prome, Des);
Variancia (Des);
getch ();
return 0;
}
void Leer_Datos (int Ca[10])
{
int i;
for (i=0; i<10; i++)
{
cout<<"\t Calificacion "<<(i+1)<<" ";
cin>>Ca[i];
}
}
int Suma_Total (int Ca[10])
{
int i, SumTot=0;
for (i=0; i<10; i++)
{
SumTot=SumTot+Ca[i];
}
return SumTot;
}
void Desviacion (int Ca[10], double Prom, double De[10])
{
int i;
for (i=0; i<10; i++)
{
De[i]=Ca[i]-Prom;
cout<<"\n\t Desviacion calificacion "<<(i+1)<<" : "<<De[i];
}
}
void Variancia (double De[10])
{
int i;
double Varia, VariaTot=0, variancia;
for (i=0; i<10; i++)
{
Varia=pow(De[i], 2.0);
VariaTot=VariaTot+Varia;
}
variancia=VariaTot/10.0;
cout<<"\n\n Variancia : "<<variancia<<endl;
}
PROBLEMA #2 DIAGRAMA DE FLUJO















PROBLEMA #3 PROGRAMA

























PROBLEMA #3 CODIGO C++
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
void introducir_datos(double resistencia[8],double corriente[8]);
void desplegar(double resistencia[8],double corriente[8],double voltage[8]);
int main()
{
double corriente[8],resistencia[8],voltage[8];
introducir_datos(resistencia,corriente);
desplegar(resistencia,corriente,voltage);
getch ();
return 0;
}
void introducir_datos(double resistencia[8],double corriente[8])
{
int i;
for(i=0;i<8;i++)
{
cout<<"introducir CORRIENTE "<<(i+1)<<":";
cin>>corriente[i];
cout<<"introducir RESISTENCIA "<<(i+1)<<":";
cin>>resistencia[i];
cout<<" "<<endl;
}
}

void desplegar(double resistencia[8],double corriente[8],double voltage[8])
{
int i;
clrscr();
cout<<"CORRIENTE RESISTENCIA VOLTAGE"<<endl;
cout<<"--------- ----------- -------"<<endl;
for(i=0;i<8;i++)
{
cout<<" "<<endl;
voltage[i]=(corriente[i])*(resistencia[i]);
cout<<setw(6)<<resistencia[i]<<setw(10)<<corriente[i]<<setw(13)<<voltage[i]<<endl;
}
}












PROBLEMA #3 PSEUDOCODIGO

























PROBLEMA #4 PROGRAMA

























PROBLEMA #4 CODIGO C++
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
int main()
{
int i, numeros[15], pos=0, neg=0;
cout<<"Introduzca 15 numeros positivos y negativos"<<endl;
for(i=0; i<15; i++)
{
cout<<"\nNumero"<<i+1<<":";
cin>>numeros[i];
}
cout<<"Numeros positivos: "<<endl;
for(i=0; i<15; i++)
{
if(numeros[i]>0)
{
pos=pos+numeros[i];
cout<<numeros[i]<<endl;
}
}
cout<<"Numeros negativos: "<<endl;
for(i=0; i<15; i++)
{
if(numeros[i]<0)
{
neg=neg+numeros[i];
cout<<numeros[i]<<endl;
}
}
cout<<"La suma de todos los numeros positivos es: "<<pos<<endl;
cout<<"La suma de todos los numeros negativos es: "<<neg<<endl;
getch();
return 0;
}
PROBLEMA #5 PROGRAMA














PROBLEMA #6 PROGRAMA











































PROBLEMA #6 CODIGO C++
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
template <class T>
void limpiararreglo(T a[11][11], char name[11][30]);
template <class T>
void lecturadatos(T a[11][11],char name[11][30], int n, int m);
template <class T>
void desplegardatos(T a[11][11],char name[11][30], int n, int m);
template <class T>
T sumavalores(T a[11][11],int n, int m);
template <class T>
void sumaderenglones(T a[11][11],int n, int m);
template <class T>
void sumadecolumnas(T a[11][11],int n, int m);
int main ()
{
int tabla[11][11];
char nombres[11][30];
int noR,noC;
cout<<"introduce el numero de alumnos (<=10) = ";
cin>>noR;
cout<<"introduce el numero de calificaciones (<=10) =";
cin>>noC;
limpiararreglo(tabla,nombres);
lecturadatos(tabla,nombres,noR,noC);
sumaderenglones(tabla,noR,noC);
sumadecolumnas(tabla,noR,noC);
cout<<"promedio de la materia programacion "<<endl<<endl;
desplegardatos(tabla,nombres,noR+1,noC+1);
getch ();
}
template <class T>
void limpiararreglo(T a[11][11],char name[11][30])
{ int r,c;
for(r=0;r<11;r++)
{
strcpy(name[r]," ");
for(c=0;c<11;c++)
{
a[r][c]=0;
}
}
}
template <class T>
void lecturadatos(T a[11][11],char name[11][30],int n, int m)
{
int r,c;
for(r=0;r<n;r++)
{
cout<<"nombre alumno "<<(r+1)<<" : ";
cin.ignore();
cin.getline(name[r],30,'\n');
for(c=0;c<m;c++)
{
cout<<"calificacion ["<<(c+1)<<" ]: ";
cin>>a[r][c];
}
cout<<endl<<endl;
}
}
template <class T>
void desplegardatos(T a[11][11],char name[11][30],int n,int m)
{
int r,c;
for(r=0;r<n;r++)
{
cout<<name[r]<<"\t";
for(c=0;c<m;c++)
{
cout<<a[r][c]<<"\t";
}
cout<<endl;
}
}
template<class T>
T sumavalores(T a[11][11],int n,int m)
{
int r,c;
T suma=0;
for(r=0;r<n;r++)
{
for(c=0;c<m;c++)
{
suma=suma+a[r][c];
}
}
return suma;
}
template <class T>
void sumaderenglones(T a[11][11],int n,int m)
{
int r,c;
T suma=0;
for(r=0;r<n;r++)
{
suma=0;
for(c=0;c<m;c++)
{
suma=suma+a[r][c];
}
a[r][m]=suma/m;
}
}
template <class T>
void sumadecolumnas(T a[11][11],int n,int m)
{
int r,c;
T suma=0;
for(c=0;c<=m;c++)
{
suma=0;
for(r=0;r<n;r++)
{
suma=suma+a[r][c];
}
a[n][c]=suma/n;
}
}
PROBLEMA #7 PROGRAMA
















PROBLEMA #8 PROGRAMA

























PROBLEMA #8 PSEUDOCODIGO

























PROBLEMA #8 DIAGRAMA DE FLUJO

También podría gustarte