Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. bool isInlier(string str)
  6. {
  7. int len = str.length();
  8. int len2 = len /2 ;
  9. for (int index = 0; index < len2; index++){
  10. if (str.at(index) != str.at(len - index -1)) return false;
  11. }
  12.  
  13. return true;
  14. }
  15.  
  16. int main(int argc, char **argv)
  17. {
  18. std::ifstream infile(argv[1]);
  19.  
  20. string line;
  21. int nInliers = 0;
  22.  
  23. while (std::getline(infile, line))
  24. if(isInlier(line))nInliers++;
  25.  
  26. cout << nInliers;
  27.  
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement