Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <locale.h>
- //Tecnica de Ordenação: Método de Seleção.
- using namespace std;
- const int n=10;
- typedef int tvet[n];
- void mostrar(tvet &vet)
- {
- for(int i=0; i<n; i++)
- cout<<vet[i]<<" ";
- }
- void ordenarSelecao(tvet &vet)
- {
- int aux, posiMin;
- for(int i=0; i<n-1; i++)
- {
- posiMin = i;
- for(int j=i+1; j<n; j++)
- if(vet[j]<vet[posiMin])
- posiMin = j;
- aux = vet[i];
- vet[i] = vet[posiMin];
- vet[posiMin] = aux;
- }
- cout<<"\n"<<endl;
- for(int i=0; i<n; i++)
- cout<<vet[i]<<" ";
- }
- int main()
- {
- setlocale(LC_ALL, "Portuguese");
- tvet vet={5, 1, 3, 6, 2, 0, 4, 8, 9, 7};
- mostrar(vet);
- ordenarSelecao(vet);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement