Advertisement
webmanix

Parte 2 Ex1

Oct 6th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int comparar(const void *x,const void *y)
  7. {
  8.     return ((*(int*)x)-(*(int*)y));
  9. }
  10.  
  11. void leitura(int vetor[])
  12. {
  13.      int i;
  14.      for(i=0;i<20;i++){
  15.                        cout << "Digite o valor na posicao "<< i+1 << endl;
  16.                        scanf("%d",&vetor[i]);
  17.                        system("CLS");
  18.                        }
  19.      }
  20.  
  21. int main(int argc, char *argv[])
  22. {
  23.     int vetor[20];
  24.     leitura(vetor);
  25.     qsort(&vetor,20,4,comparar);
  26.     system("CLS");
  27.     int i;
  28.     for(i=0;i<20;i++)cout << i+1 << ": " << vetor[i]<<endl;
  29.     system("PAUSE");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement