Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Auteur: Nicholas Thérien Roussel
- //Date: 24 octobre 2014
- #include <iostream>
- #include <string>
- using namespace std;
- bool Palindrome(string mot);
- int main()
- {
- string mot;
- cout << "Entrez un mot : ";
- cin >> mot;
- if (Palindrome(mot) == true)
- {
- cout << "Le mot est un palindrome.\n";
- }
- else
- {
- cout << "Le mot est pas un palindrome.\n";
- }
- }
- /*Donne la factorielle.
- INTRANTS:
- mot : string
- EXTRANTS:
- Palindrome : bool
- */
- bool Palindrome(string mot)
- {
- for (unsigned int i = 0; i < mot.size(); i++)
- {
- if (mot[i] == mot[mot.size() - (i+1)])
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement