-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpalindrome.cpp
More file actions
52 lines (46 loc) · 1.03 KB
/
palindrome.cpp
File metadata and controls
52 lines (46 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* =====================================================================================
*
* Filename: palindrome.cpp
*
* Description:
*
* Version: 1.0
* Created: 08/13/2015 12:56:27 AM
* Revision: none
* Compiler: gcc
*
* Author: Guilherme Alcarde Gallo (),
* Organization: UNICAMP
*
* =====================================================================================
*/
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string s;
bool palin = true;
// EOF Loop
while ( !cin.eof() )
{
palin = true;
cin >> s;
size_t i = 0, j = s.size() - 1;
// Verifying palindrome
while ( i < j )
{
// Mirrored iterator check
if ( s[i] != s[j] )
{
palin = false;
break;
}
--j;
++i;
}
cout << s << "\t" << (palin? "true" : "false") << palin << endl;
}
return 0;
}