Created
August 23, 2011 17:25
-
-
Save leostera/1165924 to your computer and use it in GitHub Desktop.
Problema 39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main (int argc, char ** argv) | |
{ | |
int n; | |
printf("Ingrese la cantidad de pares numericos (edad/altura): "); | |
scanf("%d",&n); | |
printf("Ingrese uno a uno los pares numericos, separados por una coma. Ejemplo: 24,1.8 siendo 24 los años y 1.8 la altura en metros\n"); | |
int i=0; | |
float edades[n]; | |
float alturas[n]; | |
float mayorEdad=0,mayorAltura=0,promedioEdad=0,promedioAltura=0; | |
int mayEd=0, mayAlt=0; | |
for(;i<n;++i) | |
{ | |
if(mayorEdad == 0) | |
mayorEdad = edades[i]; | |
if(mayorAltura == 0) | |
mayorAltura = alturas[i]; | |
printf("Par #%d: ", i); | |
scanf("%f,%f",&edades[i],&alturas[i]); | |
if( mayorEdad < edades[i] ) | |
{ | |
mayorEdad = edades[i]; | |
mayEd = i; | |
} | |
if( mayorAltura < alturas[i] ) | |
{ | |
mayorAltura = alturas[i]; | |
mayAlt = i; | |
} | |
promedioEdad += edades[i]; | |
promedioAltura += alturas[i]; | |
} | |
promedioEdad = promedioEdad / (n*1.0); | |
promedioAltura = promedioAltura / (n*1.0); | |
printf(" Promedio Edades -> %.2f\n Promedio Alturas -> %.2f\n Mayor Altura -> %.2f (#%d)\n Mayor Edad -> %.2f (#%d)",promedioEdad,promedioAltura,mayorAltura,++mayAlt,mayorEdad,++mayEd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment