-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1079.cpp
More file actions
52 lines (39 loc) · 837 Bytes
/
P1079.cpp
File metadata and controls
52 lines (39 loc) · 837 Bytes
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
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int is_palindrome(char str[]) {
int left = 0;
int right = strlen(str) - 1;
while (left < right) {
if (str[left] == ' ') {
left++;
continue;
}
if (str[right] == ' ') {
right--;
continue;
}
if (tolower(str[left]) != tolower(str[right])) {
return 0;
}
left++;
right--;
}
return 1;
}
int main() {
int n;
scanf("%d", &n);
getchar();
char str[1001];
for (int i = 0; i < n; i++) {
fgets(str, sizeof(str), stdin);
str[strcspn(str, "\n")] = '\0';
if (is_palindrome(str)) {
printf("Yes\n");
} else {
printf("No\n");
}
}
return 0;
}