Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. //template <typename T>
  9.  
  10. /*T kvadrat(T a){
  11.     return a*a;
  12. }*/
  13.  
  14.  
  15. int main()
  16. {
  17.     vector <int> a;
  18.     int b;
  19.     vector <int> :: iterator I;
  20.     I = a.begin();
  21.     for (int i=0; i<5; i++){
  22.         cin >> b;
  23.         if (b >= 0){
  24.             a.push_back(b);
  25.             while(I != a.end()){
  26.                 I++;
  27.                 cout << *I << endl;
  28.             }
  29.             cout << endl;
  30.         }
  31.         else{
  32.             a.insert(I, b);
  33.             while(I != a.end()){
  34.                 I++;
  35.                 cout << *I << endl;
  36.             }
  37.         }
  38.  
  39.     }
  40.  
  41.  
  42.     /*set<int>a;
  43.     set<int>::iterator I;
  44.     int b;
  45.     for (int i = 0; i < 1; i++){
  46.         cout << "введите число: " << endl;
  47.         cin >> b;
  48.         a.insert(b);
  49.     }
  50.     while(true){
  51.         cout << "введите число: " << endl;
  52.         cin >> b;
  53.         if (a.find(b) == a.end()){
  54.             a.insert(b);
  55.         }
  56.         else{
  57.             cout << "число "<< b << " есть" << endl;
  58.         }
  59.     }*/
  60.  
  61.  
  62.     /*I = a.begin();
  63.     cout << *I << endl;
  64.     I++;
  65.     cout << *I << endl;
  66.     I++;
  67.     cout << *I << endl;
  68.     I++;
  69.     if (I ==  a.end()){
  70.         cout << "end" << endl;
  71.     }*/
  72.  
  73.     //cout << kvadrat(5.7) << endl;
  74.  
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement