Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. //Auteur: Nicholas Thérien Roussel
  2. //Date: 24 octobre 2014
  3.  
  4. #include <iostream>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. bool Palindrome(string mot);
  10.  
  11. int main()
  12. {
  13.    string mot;
  14.  
  15.    cout << "Entrez un mot : ";
  16.    cin >> mot;
  17.  
  18.    if (Palindrome(mot) == true)
  19.    {
  20.       cout << "Le mot est un palindrome.\n";
  21.    }
  22.    else
  23.    {
  24.       cout << "Le mot est pas un palindrome.\n";
  25.    }
  26. }
  27.  
  28. /*Donne la factorielle.
  29. INTRANTS:
  30. mot : string
  31.  
  32. EXTRANTS:
  33. Palindrome : bool
  34. */
  35. bool Palindrome(string mot)
  36. {
  37.    for (unsigned int i = 0; i < mot.size(); i++)
  38.    {
  39.       if (mot[i] == mot[mot.size() - (i+1)])
  40.       {
  41.          return true;
  42.       }
  43.       else
  44.       {
  45.          return false;
  46.       }
  47.    }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement