1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 15:48:42 +00:00
202401-programming-assignments/【实践课外】9.数组3/7-3 数组-回文串.c

32 lines
479 B
C
Raw Normal View History

2024-11-15 09:07:17 +00:00
#include <stdio.h>
#include <string.h>
int n;
char s[1005];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%s", s);
int flag = 1;
// check is palindrome
for (int j = 0; j < strlen(s) / 2; j++) {
if (s[j] != s[strlen(s) - j - 1]) {
flag = 0;
break;
}
}
if (flag) {
printf("%s\n", s);
}
}
return 0;
}