Форум » C/C++ для начинающих (C/C++ for beginners) » Basic Palindrome vector » Ответить

Basic Palindrome vector

Felicia123: [pre2]#include <iostream> #include <vector> #include <string> using namespace std; int main(){ string words; cout <<"Enter words : " ; getline( cin,words ); string wordsReverse( words.rbegin() , words.rend() ); cout << "\nBackwards , it's : " << wordsReverse << endl << endl; if( words == wordsReverse ) cout << words << " is a palindrome !" << endl; else cout << words << " is not a palindrome ! " << endl; system( "pause" );//Pause window return 0;//Exit Program }[/pre2] i know it's not hard . but the problem is , here is the question A palindrome is a sequence of characters, numbers or words that have the property of reading the same in either direction (backwards or forwards). In a palindrome white space and punctuation have no significance (they are typically ignored). Examples of palindromes are shown below. 121 - A numeric sequence GACTTCAG - A DNA Sequence Sator Arepo tenet opera rotas - A latin phrase for: The farmer by his labour keeps the wheels to the plough. As you can see in the last example, white space and capitalisation are ignored. You are to write a program that takes in a sequence and works out if it is/isn’t a palindrome. We are going to do this in three different ways. how to ignore capitalisation and while space ? Besides that . how to change the iterator STL to vector STL ?

Ответов - 39, стр: 1 2 All



полная версия страницы