Mirrored Palindrome

The code is supposed to check whether the entered text is a palindrome or a mirrored string but it does not print anything when I input something. Any ideas?

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main () 
{
	bool palindrome =false ;
	bool mirrored =false ;
	char word[1000];
	cin >> word;

	int x= strlen(word);
	int y= strlen(word)-1;
	
	for ( int a=0; a<x; a++)
	{	
		if (word [a] == word [y-a] )
		{
			 palindrome = true;
			
		}
	}
	for ( int c=0; c<x; c++)
		{
	
			switch (word [c])
			{
				case 'A': return 'A';
				case 'E': return '3';
				case 'H': return 'H';
				case 'I': return 'I';
				case 'J': return 'L';
				case 'M': return 'M';
				case 'O': return 'O';
				case 'S': return '2';
				case 'T': return 'T';
				case 'U': return 'U';
				case 'V': return 'V';
				case 'W': return 'W';
				case 'X': return 'X';
				case 'Y': return 'Y';
				case 'Z': return '5';
				case 'B': return 'C';
				case 'C': return 'D';
				case 'D': return 'F';
				case 'F': return 'G';
				case 'G': return 'K';
				case 'K': return 'N';
				case 'N': return 'P';	
				case 'P': return 'P';
				case 'Q': return 'R';
				case 'R': return 'B';
			}
 	if (word [c] == word [y-c] )
		{
			 mirrored = true;
		}
		}
		
			


	if (palindrome == true && mirrored==false)
	{
		cout << "Is a palindrome " << "\n";
	}
	
	if (mirrored== true && palindrome==false)
	{
		cout << "Is a mirrored string" << "\n";
	}
	
	if (palindrome == true && mirrored == true)
	{ 
		cout << "Is a mirrored palindrome" << "\n";
	}
	if (palindrome == false && mirrored == false)
	{ 	
		cout << "Is not a palindrome" << "\n";
	}
	
	return 0;

}
1
2
3
switch (word [c])
{
	case 'A': return 'A';
¿what do you expect to happen there? `return' would terminate the function
What's the difference between a palindrome and a mirrored string?
closed account (LzwkoG1T)
Return wouldn't do anything as ne555 said. You can print it out instead.

Josie,I think palindromes apply only to numbers, eg : 121 , mirrored strings apply to..well, strings.
The code is supposed to check whether the entered text is a palindrome or a mirrored string...

This confuses me.
Palindromes do apply to words, numbers and even entire poems (http://www.palindrome.de/content/palin.html). I'm not sure what the difference between a mirrored string and a palindrome could be though?
Haha! These people have their own definitions. :-)
Topic archived. No new replies allowed.