Você está na página 1de 2

#include <stdio.

h>
#include <stdlib.h>
struct arrayDeDados {
int num;
} numeros[200];
struct arrayImpares {
int numImpar;
} numerosImpares[200];
struct minimo {
int numMenor;
} menor[1];
int main()
{
int op,n,i;
i=0;
op=0;
while(op!=2){
printf("Por favor, digite um numero inteiro nao negativo: ");
scanf("%d", &n);
numeros[i].num = n;
++i;
if (n <= 0) {
printf("O numero digitado nao esta em conformidade com o solicitado.
Por favor, tente novamente. \n");
} else {
printf("\n\t\t\t MENU \n** Voce gostaria de digitar mais algum numer
o? \n\n ** 1 - SIM \n ** 2 - NAO \n");
scanf("%d", &op);
switch (op)
{
case 1:
{
break;
}
case 2:
{
MontarArrayDeNumerosImpares(n);
}
}
}
}
}
int MontarArrayDeNumerosImpares(int num) {
int cont=0;
int j=0;
while (cont<= (sizeof(numeros)/sizeof(int))) {
if (numeros[cont].num % 2 != 0)
{
numerosImpares[j].numImpar = numeros[cont].num;
++j;
}
cont++;
}
//ordernarArray(numerosImpares, (sizeof(numerosImpares)/sizeof(int)));
ordernarArray(j);
return(1);
}
void ordernarArray (int V[], int tam)
{
int k,l,aux;
for (k = 1; k < tam; ++k)
{
l = k;
while ((l != 0) && (V[l] < V [l - 1]))
{
aux = V[l];
V[l] = V[l - 1];
V[l - 1] = aux;
--l;
}
}
verifica_menor_numero(l);
}
int verifica_menor_numero(int nume) {
int cont=0;
int c=0;
while (cont<=(sizeof(numerosImpares)/sizeof(int))) {
if (numerosImpares[c].numImpar > numerosImpares[cont].numImpar)
{
c = cont;
}
cont++;
}
printf("O menor numero impar digitado foi: %d", numerosImpares[0].numImpar);
return(1);
}

Você também pode gostar