1

I can't find why compiler is throwing error

#include <bits/stdc++.h>
using namespace std;

int main() 
{
  vector<vector<int>>vec;
  for(int i=0;i<10;i++)
  {
    vector<int>veck;
    for(int j=0;j<10;j++)
    if(j==5)
    veck.emplace_back(5);
    else
    veck.emplace_back(i);
    vec.emplace_back(veck);
  }
  for(auto i:vec){
  for(auto j:i)
  cout<<j<<" ";
  cout<<"\n";}
  
  //-------------------------------
  
  vector<int>vecx(5,4);
  vecx.emplace_back(5);
  for(auto i :vec)
  {
    auto itr=find(i.begin(),i.begin()+vecx.size(),vecx);
    if(itr!=i.begin()+vecx.size())
    cout<<"YES";
  }

}

why it is not compiling... Can Someone assist me, I need to check whether any of the rows in vector-vec is containing vector-vecx..

Zero
  • 37
  • 6
  • If it's not compiling, presumably the compiler is giving you an error message. Why not add it to your question? – Passerby Oct 23 '21 at 10:06
  • Add #include and #include and remove using namespace std, and prefix std types with std:: (https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice/1453605) – Pepijn Kramer Oct 23 '21 at 10:14
  • @Passerby Absolutely :) should have been iostream! Thanks for the headsup – Pepijn Kramer Oct 23 '21 at 10:18
  • @Passerby you edit the question – Zero Oct 23 '21 at 10:19
  • @Zero I can't edit the question with the error message you are getting because I don't know what it is. – Passerby Oct 23 '21 at 10:20
  • @Passerby neither do I :) – Zero Oct 23 '21 at 10:24
  • You said the code is not compiling, but you don't know the compiler error message? I don't get it. – Passerby Oct 23 '21 at 10:27
  • @Passerby No I can't understand the error. it was like 500 lines errors. – Zero Oct 23 '21 at 10:28
  • @Passerby And I'm new to STL so it is really hard for me to figure out – Zero Oct 23 '21 at 10:29
  • 1
    You ask `std::find` to find a value of type `vector` in a container whose elements are `int`. If you are trying to see whether `vecx` is a subsequence of `i`, you need [`std::search`](https://en.cppreference.com/w/cpp/algorithm/search), not `std::find` – Igor Tandetnik Oct 23 '21 at 13:42

0 Answers0