Advertisement
toribio

toribio

Dec 8th, 2010
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <conio.h>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char** argv)
  9. {
  10.     int n;
  11.     vector<int> v;
  12.  
  13.     cout << "Insira um numero e pressione ENTER, repita o processo quantas vezes quiser:" << endl;
  14.     cout << "Insira o numero -1 para encerrar o processo e fazer a ordenacao dos numeros." << endl << endl;
  15.  
  16.     do
  17.     {
  18.         cin >> n;
  19.         v.push_back(n);
  20.     }
  21.     while(n != -1);
  22.  
  23.     v.erase(v.end() - 1);
  24.     sort(v.begin(), v.end());
  25.     cout << endl;
  26.  
  27.     for(unsigned int i = 0; i < v.size(); ++i)
  28.     {
  29.         cout << "Item " << i << ": " << v.at(i) << endl;
  30.     }
  31.     return EXIT_SUCCESS;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement