[ create a new paste ] login | about

Link: http://codepad.org/WvvskYlg    [ raw code | output | fork ]

Saumya_Agnihotri - C++, pasted on Jul 3:
#include<bits/stdc++.h>
using namespace std;

bool myfunction (int i, int j) {
  return (i==j);
}

int main () {
   
   int input, i, n;
  std::vector<int> myvector;
  cin>>n;
  for(i =0; i< n;i++)
  {     cin>>input;                                         // eg : 10 20 20 20 30 30 20 20 10
        myvector.push_back(input);    }
    sort(myvector.begin(), myvector.end());

  // using default comparison:
  std::vector<int>::iterator it;
  it = std::unique (myvector.begin(), myvector.end());   // 10 20 30 20 10 ?  ?  ?  ?
                                                                        

  myvector.resize( std::distance(myvector.begin(),it) ); // 10 20 30 20 10

  // using predicate comparison:
  std::unique (myvector.begin(), myvector.end(), myfunction);   // (no changes)

  // print out content:
  std::cout << "myvector contains:";
  for (it=myvector.begin(); it!=myvector.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '\n';

  return 0;
}


Output:
1
Line 23: error: bits/stdc++.h: No such file or directory


Create a new paste based on this one


Comments: