Escolar Documentos
Profissional Documentos
Cultura Documentos
OBS: A ORDENAO DE QUE TRATA O ITEM 8, SERA FEITA COM O METODO BOLHA
O PROGRAMA S PODE DECLARAR UM UNICO ARRAY UNIDIMENSIONAL (VETOR)
FOR
IF
ELE
WHILE
OPERADOR
PRINTF
SCANF
BOLHA
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause")
or input loop */
somaposimp = 0;
for(i=1; i<20; i=i+2)
somaposimp = somaposimp + colecao[i];
mediaposimp = somaposimp / 10;
printf("\n A MEDIA DAS POSICOES IMPARES: %d", mediaposimp);
menornumero = colecao[0];
for (i=0;i<20;i++)
{
if (colecao[i] < menornumero)
menornumero=colecao[i];
}
fatorial=1;
for( aux=menornumero;aux>1; aux--)
fatorial = fatorial * aux;
printf("\n O FATORIAL DO MENOR NUMERO: %d\n\n", fatorial);
printf ("\n VETOR INVERTIDO : ");
for (i=20; i>=0; i--)
printf ( " %d ", colecao[i]);
ordcrescente=20;
while(ordcrescente > 1)
{for(i=0;i<20;i++)
{if(colecao[i] > colecao[i+1])
{aux=colecao[i];
colecao[i]=colecao[i+1];
colecao[i+1]=aux;
}
}
ordcrescente=ordcrescente-1;
}
printf("\n VETOR EM ORDEM CRESCENTE: ");
for (i=20; i>=0; i--)
{printf(" %d",colecao[i]);
}
return 0;
}
primeiro = ultimo
segundo = penul
terceiro = ante
...
mostrar coleo invertida*/