Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main(void)
- {
- int quantidade,a,b,flag;
- char string[101],copia[101];
- scanf("%d%s",&quantidade,string);
- strcpy(copia,string); // faz uma copia da string, para comparar o inicio de uma com o final da outra
- for(a = 0, b = quantidade -1; a < quantidade && b >= 0;a++,b--)
- if(string[a] == copia[b]) // Se o inicio de uma for igual ao final de outra
- flag = 1; // é palíndromo
- else
- flag = 0;
- if(flag)
- printf("eh palindromo\n");
- else
- printf("nao eh palindromo\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement