LAB_2

#include<iostream>
#include<math.h>
using namespace std;
// ZONA DE DECLARACION DE LOS VECTORES
//# DEFINE TAM 10;
const int TAM=10;
int menos, mas, presion[TAM];
int p1[100],p2[100],n,s[100];
void CARGAR(int p[],int n);
void SUMAR( int p1[],int p2[], int s[], int n);
void MOSTRAR(int p[], int n);
int c, i;
double P, fo;
// ZONA DE DECLARACION DE LOS VECTORES
//# DEFINE TAM 10;
int j;
int main ()
{
//1)DECLARACION
int opcion;
do
{ // INICIO DEL DO - WHILE
cout<<"*********MENU DE FUNCIONES *************************\n\n";
cout<<" 1) LECTURA DE PRESIONES \n";
cout<<" 2) IMPRESION O ESCRITURA DE LA PRESION \n";
cout<<" 3) PROCESAR EL MAXIMO \n";
cout<<" 4) PROCESAR EL MINIMO \n";
cout<<" 5) SUMA DE ELEMENTOS DE LA PRESION \n";
cout<<" 6) CONTAR \n";
cout<<" 7) CONTAR VECES QUE SE REPITE LA PRESION \n";
cout<<" 8) APLICANDO EN LA FORMULA \n";
cout<<" DIGITE <0> PARA SALIR \n\n";
cout<<"*************************************************\n\n";
cout<<" ELIJA UNA OPCION : "; cin>>opcion;
//2)ASIGNACION
switch (opcion)
{
case 1:
{
cout<<"******* LECTURA DE PRESIONES *********************\n\n";
for (i=1; i<=4; i++)
{
cout<<"INGRESE LA PRESION P[ "<<i<<" ] = "; cin>>presion[i];
}
cout<<endl;
cout<<"**********************************************\n\n";
} //FIN DEL CASO 1
break;
case 2:
{
cout<<"******* IMPRESION O ESCRITURA DE LA PRESION *********************\n\n";
for (i=1; i<=4; i++)
{
cout<<" EL ELEMENTO P[ "<<i<<" ] = "<<presion[i]<<endl;
}
cout<<endl;
cout<<"**********************************************\n\n";
} //FIN DEL CASO 1
break;

case 3:
{
cout<<"******* PROCESAR EL MAXIMO *********************\n\n";
int max=0;
for (i=1; i<=4; i++)
{
if(presion[i]>max)
max = presion[i];
}
// RESULTADO
cout <<" EL MAXIMO ES: "<<max;
cout<<endl;
cout<<"**********************************************\n\n";
} //FIN DEL CASO 2
break;
case 4:
{
cout<<"******* PROCESAR EL MINIMO ******\n\n";
int min=100;
for (i=1; i<=4; i++)
{
if(presion[i]<min)
min = presion[i];
}
// RESULTADO
cout <<" EL MINIMO ES: "<<min;
cout<<endl;
cout<<"**********************************************\n\n";
} //FIN DEL CASO 3
break;
case 5:
{
cout<<"******* SUMA DE PRESIONES ******\n\n";
int suma = 0;
for (i=1; i<=4; i++)
suma = suma + presion[i];
cout<<"--------------------------- \n ";
cout<<"LA SUMA DE LOS ELEMENTOS ES: "<< suma << endl;
cout << endl;
cout<<"********************************\n\n";

} //FIN DEL CASO 4
break;
case 6:
{
cout<<"******* CONTAR ************************\n\n";
c = 0;
for (i=1; i<=4; i++)
{
//Elemento = 4;
if (presion[1] == presion[i])
{
c = c + 1;
cout<<"ESTA EN EL INDICE "<<i <<" VALOR ES: "<<presion[i]<< endl;
}
}
cout<<"EL PRIMER ELEMENTO SE REPITE "<< c <<" VECES"<< endl;
cout << endl;
cout<<"*************************************\n\n";
} //FIN DEL CASO 6
break;
case 7:
{
cout<<"******* CONTAR VECES QUE SE REPITE EL ELEMENTO ******\n\n";
for (i=1; i<=4; i++)
{
c = 0;
// Elemento = Vector[i];
for (j=1; j<=4
; j++)
{
if (presion[i] == presion[j])
{
c = c + 1;
}
}// segundo for
cout<<"EL VALOR "<<presion[i] <<" se repite "<<c<<" veces"<< endl;
}// primer for
cout<< endl;
cout<<"******************************************\n\n";
cout<<endl;
} //FIN DEL CASO 7
break;
case 8:
{
cout<<"******* APLICANDO EN LA FORMULA *******\n\n";
cout<<"ingrese una presion "<<endl;
cin>>n;
CARGAR(p1,n);
CARGAR(p2,n);
SUMAR(p1,p2,s,n);
MOSTRAR(s,n);
/*
menos = 0;
mas = 0;
for(i=1; i<=TAM; i++)
{
if (presion[i]<10)
menos = menos + 1;
if (presion[i]>10)
mas = mas + 1;
}
cout<<"HAY "<<menos<<" MENORES a 10"<< endl;
cout<<"HAY "<<mas<<" MAYORES a 10";
*/
cout<<endl;
cout<<"******************************************\n\n";
cout<<endl;
} //FIN DEL CASO 10
break;

}// FIN DE SWITCH
} // FIN DEL DO - WHILE
while (opcion !=0);
cout<<endl;cout<<"\n";
return 0;
}//FIN DEL PROGRAMA
// ZONA DE DELARACION
void CARGAR(int p[],int n)
{
int i;
cout<<"cargar la presion"<<endl;
for(i=1;i<=n;i++)
{
cout<<"Ingrese la presion p["<<i<<"]= "; cin>>p[i];
}
}
void SUMAR( int p1[],int p2[], int s[], int n)
{
int i;
for(i=0;i<n;i++)
{
s[i]=p1[i]+p2[i];
}
}
void MOSTRAR(int p[], int n)
{
int i;
cout<<"la presion es"<<endl;
for(i=0;i<n;i++)
{
cout<<p[i]<<endl;
}
}

No hay comentarios:

Publicar un comentario