#include <bits/stdc++.h>
using namespace std;
const int n=100;
int main()
{
int j,aux,i;
//criando o vetor
int *A=(int*) malloc(n*sizeof(int));
//preenchendo o vetor.
srand(time(NULL));
for(int i=0; i<n; i++, A++)
{
*A=rand()%50*10;
}
//apontando o vetor para o primeiro elemento.,
A-=n;
//imprimindo o vetor.
cout<<"Vetor aleatorio.";
for(int i=0; i<n; i++, A++)
{
cout<< *A<<" ";
}
A-=n;
//ordena o vetor .
for(i=0; i < (n-1); i++)
{
for(j=0; j < (n-i-1); j++)
{
if(A[j] > A[j+1])
{
aux=A[j];
A[j]=A[j+1];
A[j+1]=aux;
}
}
}
//imprime o vetor ordenado
cout<<"Vetor ordenado:\n";
for(i=0; i<n; i++, A++)
{
cout<<*A<<" ";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgbj0xMDA7CgppbnQgbWFpbigpCnsKICAgIGludCBqLGF1eCxpOwogICAgLy9jcmlhbmRvIG8gdmV0b3IKICAgIGludCAqQT0oaW50KikgbWFsbG9jKG4qc2l6ZW9mKGludCkpOwoKICAgIC8vcHJlZW5jaGVuZG8gbyB2ZXRvci4KICAgIHNyYW5kKHRpbWUoTlVMTCkpOwogICAgZm9yKGludCBpPTA7IGk8bjsgaSsrLCBBKyspCiAgICB7CiAgICAgICAgKkE9cmFuZCgpJTUwKjEwOwogICAgfQogICAgLy9hcG9udGFuZG8gbyB2ZXRvciBwYXJhIG8gcHJpbWVpcm8gZWxlbWVudG8uLAogICAgQS09bjsKICAgIC8vaW1wcmltaW5kbyBvIHZldG9yLgogICAgY291dDw8IlZldG9yIGFsZWF0b3Jpby4iOwogICAgZm9yKGludCBpPTA7IGk8bjsgaSsrLCBBKyspCiAgICB7CiAgICAgICAgY291dDw8ICpBPDwiICI7CiAgICB9CiAgICBBLT1uOwogICAgLy9vcmRlbmEgbyB2ZXRvciAuCiAgICBmb3IoaT0wOyBpIDwgKG4tMSk7IGkrKykKICAgIHsKICAgICAgICBmb3Ioaj0wOyBqIDwgKG4taS0xKTsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoQVtqXSA+IEFbaisxXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYXV4PUFbal07CiAgICAgICAgICAgICAgICBBW2pdPUFbaisxXTsKICAgICAgICAgICAgICAgIEFbaisxXT1hdXg7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgoKICAgIC8vaW1wcmltZSBvIHZldG9yIG9yZGVuYWRvCiAgICBjb3V0PDwiVmV0b3Igb3JkZW5hZG86XG4iOwogICAgZm9yKGk9MDsgaTxuOyBpKyssIEErKykKICAgIHsKICAgICAgICBjb3V0PDwqQTw8IiAiOwogICAgfQoKICAgIHJldHVybiAwOwp9