Está en la página 1de 3

// EXAMEN FINAL LUIS LOPEZ.

cpp: define el punto de entrada de la aplicación de con


sola.
//

#include "stdafx.h"
#include "string.h"
#include "conio.h"
#include "stdlib.h"
#define CNT_MAYOR 18
int VLV,VOPCION,CO_MAYOR,CO_MENOR,VPROM;
int VEC_1[30];

void Ingreso_vector (int PLV)


{
for (int vsi = 1 ;vsi <= PLV ; vsi++)
{
printf ("Inserte Vec pos.[%d]: ",vsi);
scanf_s("%d",&VEC_1[vsi]);
}
}
void calculo(int PLV)
{
int AC_SUMA;
CO_MAYOR=0;
CO_MENOR=0;
AC_SUMA=0;
VPROM=0;
for (int vsi = 1 ;vsi <= PLV ; vsi++)
{
AC_SUMA = AC_SUMA + VEC_1[vsi];
if (VEC_1[vsi] > CNT_MAYOR)
{
CO_MAYOR++;
}
else
{
CO_MENOR++; }
}
VPROM = AC_SUMA / PLV;
}
void mostrar (int PLV, int PNUM_OPCION)
{
switch (PNUM_OPCION)
{
case 1:
for (int vsi = 1 ; vsi <= PLV ; vsi++)
{
printf ("Vec pos.[%d]: ",vsi);
printf ("%d \n",VEC_1[vsi]);
}
break;
case 2:
printf ("Existen %d: Mayores DE EDAD",CO_MAYOR);
printf("\n");
printf ("Existen %d: Menores DE EDAD",CO_MENOR);
printf("\n");
printf ("El RANGO DE EDAD ES DE %d:" ,VPROM);
break;
}
}
void Menu()
{
int vsbandera;
vsbandera=1;
while (vsbandera!=0)
{
system ("cls");
printf("\n");
printf("*****\n");
printf("***** Algoritmo Ingreso de 1 vector, CALCULAR e impresion de vector**
***\n");
printf("*****\n");
printf("\n");
printf("***** MENU PRINCIPAL *****\n");
printf("***** OPCION 1 INGRESO DE DATOS *****\n");
printf("***** OPCION 2 CALCULO DE MAYOR/MENOR DE EDAD Y RANGO *****\n");
printf("***** OPCION 3 SALIR *****\n");
printf("***** INGRESE OPCION *****\n");
scanf_s("%d",&VOPCION);
switch (VOPCION)
{
case 1:
printf ("Inserte dimen. del vector: ");
scanf_s("%d",&VLV);
Ingreso_vector(VLV);
while (getchar() != '\n');
break;
case 2:
calculo (VLV);
mostrar (VLV,1);
getchar();
printf("\n");
mostrar (VLV,2);
getchar();
break;
case 3:
printf("\n");
printf("\nPulse cualquier tecla para continuar");
getchar();
vsbandera=0 ;
break;
}
}
}
int main ()
{
Menu();
return 0;
}

También podría gustarte