Dev Skill problem DCP-25: Palindrome Solution
Problem Link
Dev Skill problem DCP-25: Palindrome Solution
Solution:
Dev Skill problem DCP-25: Palindrome Solution
Solution:
#include <stdio.h>
#include <string.h>
int main()
{
char word[100], reverse_word[100];
int i, j,k, len,n;
scanf("%d",&n);
for(k=0;k<n;k++)
{
getchar();
scanf("%s",word);
len = strlen(word);
lower_string(word);
for(i = 0, j = len - 1; i < len; i++, j--) {
reverse_word[i] = word[j];
}
reverse_word[i] = '\0';
if (0 == strcmp(word, reverse_word)) {
printf("Yes\n");
}
else {
printf("No\n");
}
}
return 0;
}
void lower_string(char s[]) {
int c = 0;
while (s[c] != '\0') {
if (s[c] >= 'A' && s[c] <= 'Z') {
s[c] = s[c] + 32;
}
c++;
}
}
No comments