fork(4) download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <algorithm>
  5. using namespace std;
  6. int main()
  7. {
  8. vector<vector<string> > ptextarr = {{"this", "is", "a", "test"},
  9. {"this"},
  10. {"is", "one", "as", "well"},
  11. {"the", "word", "root", "is", "here"},
  12. {"and", "here:", "root"}};
  13. for(size_t n = 0; n < ptextarr.size(); ++n)
  14. {
  15. auto i = find(ptextarr[n].begin(), ptextarr[n].end(), "root");
  16. if(ptextarr[n].end() != i)
  17. std::cout << "Found root at row " << n << " col " << i-ptextarr[n].begin() << '\n';
  18. }
  19. }
Success #stdin #stdout 0s 2964KB
stdin
Standard input is empty
stdout
Found root at row 3 col 2
Found root at row 4 col 2