Gustastrada 04/10/2019 #include #include #include #include int main() { setlocale(LC_ALL,"PORTUGUESE"); srand(time(NULL)); //CRIAR VARS int i, j, aux, vet[8]; //INICIALIZAR VARS for(i=0; i<8; i++) vet[i] = 0; aux = 0; //PREENCHER E EXIBIR VETOR printf(" "); printf(" || PREENCHIMENTO DO VETOR ||"); printf(" "); for(i=0; i<8; i++) { vet[i] = rand() % 100; printf(" VETOR POSIÇÃO [%2d]: %2d ",i+1,vet[i]); } //ORDENAR VETOR for(i=0; i<8; i++) { for(j=0; j<7; j++) { if(vet[i] < vet[j]) { aux = vet[j]; vet[j] = vet[i]; vet[i] = aux; } } } //EXIBIR VETOR ORDENADO printf(" "); printf(" || VETOR ORDENADO ||"); printf(" "); for(i=0; i<8; i++) printf(" VETOR POSIÇÃO [%2d]: %2d ",i+1,vet[i]); return 0; }
Gustastrada
#include
#include
#include
#include
int main()
{
setlocale(LC_ALL,"PORTUGUESE");
srand(time(NULL));
//CRIAR VARS
int i, j, aux, vet[8];
//INICIALIZAR VARS
for(i=0; i<8; i++)
vet[i] = 0;
aux = 0;
//PREENCHER E EXIBIR VETOR
printf(" ");
printf(" || PREENCHIMENTO DO VETOR ||");
printf(" ");
for(i=0; i<8; i++)
{
vet[i] = rand() % 100;
printf(" VETOR POSIÇÃO [%2d]: %2d ",i+1,vet[i]);
}
//ORDENAR VETOR
for(i=0; i<8; i++)
{
for(j=0; j<7; j++)
{
if(vet[i] < vet[j])
{
aux = vet[j];
vet[j] = vet[i];
vet[i] = aux;
}
}
}
//EXIBIR VETOR ORDENADO
printf(" ");
printf(" || VETOR ORDENADO ||");
printf(" ");
for(i=0; i<8; i++)
printf(" VETOR POSIÇÃO [%2d]: %2d ",i+1,vet[i]);
return 0;
}