Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- int main ()
- {
- char palin[50];
- char frase[50];
- char frase2[50];
- int n;
- int i,cantidad,cont;
- printf("Idatzi esaldi bat:\n");
- gets(frase);
- n=0;
- while (frase[n]!='\0')
- {
- if (isupper(frase[n])) {
- frase2[n]=tolower(frase[n]);
- } else{
- frase2[n]=frase[n];
- }
- if (frase2[n] != ' ' && frase2[n] != ',' && frase2[n] != '?' && frase2[n] != '¿' && frase2[n] != '!' && frase2[n] != '¡' && frase2[n] != ';' && frase2[n] != ':' && frase2[n] != '.')
- {
- palin[n]=frase2[n];
- printf("%c", palin[n]);
- n++;
- } else {
- n++;
- }
- }
- i = strlen(palin);
- for(cont=0;cont<i;cont++){
- if(palin[cont] == palin[(i-cont)-1])
- {
- cantidad = 0;
- } else {
- cantidad = 1;
- break;
- }
- }
- if(cantidad==0) {
- printf("La frase es palindroma.\n");
- } else {
- printf("La frase no es palindroma.\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement