Informática, perguntado por joedsonalves3823, 9 meses atrás

faça um programa que receba 10 número inteiro e ordene crescentemente​


Speedhack: Qual lang?

Soluções para a tarefa

Respondido por Gabrielmartinsseco
0

Resposta:

#include <stdio.h>

#include <stdlib.h>

#include <locale.h>

int main()

{

   setlocale(LC_ALL,"PORTUGUESE");

   //CRIAR VARS

   int i, j, aux, vet[10];

   //INICIALIZAR VARS

   for(i=0; i<10; i++)

       vet[i] = 0;

   i = j = aux = 0;

   //RECEBER E PROCESSAR DADOS

   printf("\n\n\tINSIRA OS VALORES:\n");

   for(i=0; i<10; i++)

   {

       printf("\n\n INFORME O %2d° VALOR..: ",i+1);

       fflush(stdin);

       scanf("%d", &vet[i]);

   }

   //ORDENAR VALORES CRESCENTEMENTE

   for(i=0; i<10; i++)

   {

       for(j=0; j<9; j++)

       {

           if(vet[i] < vet[j])

           {

               aux = vet[j];

               vet[j] = vet[i];

               vet[i] = aux;

           }

       }

   }

   //EXIBIR VALORES ORDENADOS

   printf("\n\n\t=======================");

   printf("\n\t|| VALORES ORDENADOS ||");

   printf("\n\t=======================\n\n");

   for(i=0; i<10; i++)

       printf(" %2d° VALOR: %d\n\n",i+1,vet[i]);

   return 0;

}

Perguntas interessantes