JosepRivaille

P59497: És un palíndrom?

Apr 29th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. bool es_palindrom(const string& s) {
  6.     int i = 0;
  7.     int k = s.size();
  8.     --k;
  9.     while (i < k) {
  10.         if (s[i] != s[k]) return false;
  11.         ++i;
  12.         --k;
  13.     }
  14.     return true;
  15. }
Add Comment
Please, Sign In to add comment