#include <stdio.h>
#include <stdlib.h>

#define MAX 30
/*
* =================================================
*    Filename:  .c
* Description:
*     Created:  dd/mm/18 hh:mm
* =================================================
*/

int main(int argc, char **argv)
{
	int input;
	float num[MAX], odd[MAX], even[MAX], sum = 0;
	float bigger, lower, even_counter = 0, odd_counter = 0;

	do
	{
		printf("Entre com a quantidade de números inteiros (max. 30): ");
		scanf("%d", &input);
		if(input > MAX)
			printf("Erro! O número máximo permitido é 30.\n");
	} while(input > MAX);

	for(int i = 0;i < input; i++)
	{
		printf("Digite o valor %d: ", i+1);
		scanf("%f", &num[i]);

		if((int)num[i] % 2 == 0)
		{
			even[i] = num[i];
			even_counter++;
		}
		else
		{
			odd[i] = num[i];
			odd_counter++;
		}
	}


	printf("Impares: {");
	for(int i = 0;i < input; i++)
	{
		if(i % 2 == 0)
		{
			printf("%f, ", odd[i]);
			sum += odd[i];
			lower = odd[0];
			bigger = odd[0];
			if(odd[i] < lower) lower = odd[i];
			if(odd[i] > bigger) bigger = odd[i];
		}
	}
	printf("}\n");
	printf("Media: %f\nMaior: %f\nMenor: %f\nSoma: %f\n\n", sum/odd_counter, bigger, lower, sum);


	printf("Pares: {");
	for(int i = 0;i < input;i++)
	{
		if(i % 2 != 0)
		{
			printf("%f, ", even[i]);
			sum += even[i];
			// even[0] não funcionou
			lower = even[1];
			bigger = even[1];
			if(even[i] < lower) lower = even[i];
			if(even[i] > bigger) bigger = even[i];
		}
	}
	printf("}\n");
	printf("Media: %f\nMaior: %f\nMenor: %f\nSoma: %f\n\n", sum/even_counter, bigger, lower, sum);

    return 0;
}

