-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVA401.cpp
More file actions
67 lines (67 loc) · 1.2 KB
/
UVA401.cpp
File metadata and controls
67 lines (67 loc) · 1.2 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int palj(char[]);
void change(char[]);
int main()
{
char in[100],in1[100];
while (gets_s(in,100) != NULL) {
int pal = 0, mir = 0,p=strlen(in)-1,pm;
pal = palj(in);
strcpy(in1,in);
change(in1);
mir = palj(in1);
pm = pal * 10 + mir;
switch (pm)
{
case 00: printf("%s -- is not a palindrome.\n\n",in);
break;
case 10: printf("%s -- is a regular palindrome.\n\n", in);
break;
case 01: printf("%s -- is a mirrored string.\n\n", in);
break;
case 11: printf("%s -- is a mirrored palindrome.\n\n", in);
break;
}
}
}
int palj(char test[]) {
int h = strlen(test) - 1, low = 0,notpal=0;
while (low < h) {
if (test[h] != test[low]) {
notpal = 1;
break;
}
low++;
h--;
}
if (notpal)
return 0;
else
return 1;
}
void change(char test[]) {
int i = 0,l=strlen(test)/2;
while (i<l) {
switch (test[i]) {
case 'E': test[i] = '3';
break;
case 'J': test[i] = 'L';
break;
case 'L': test[i] = 'J';
break;
case 'S': test[i] = '2';
break;
case 'Z': test[i] = '5';
break;
case '2': test[i] = 'S';
break;
case '3': test[i] = 'E';
break;
case '5': test[i] = 'Z';
break;
}
i++;
}
}