Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. int main ()
  6. {
  7.  
  8. char palin[50];
  9. char frase[50];
  10. char frase2[50];
  11. int n;
  12. int i,cantidad,cont;
  13.  
  14. printf("Idatzi esaldi bat:\n");
  15.  
  16. gets(frase);
  17.  
  18. n=0;
  19.  
  20. while (frase[n]!='\0')
  21. {
  22. if (isupper(frase[n])) {
  23. frase2[n]=tolower(frase[n]);
  24. } else{
  25. frase2[n]=frase[n];
  26. }
  27. if (frase2[n] != ' ' && frase2[n] != ',' && frase2[n] != '?' && frase2[n] != '¿' && frase2[n] != '!' && frase2[n] != '¡' && frase2[n] != ';' && frase2[n] != ':' && frase2[n] != '.')
  28. {
  29. palin[n]=frase2[n];
  30. printf("%c", palin[n]);
  31. n++;
  32. } else {
  33. n++;
  34. }
  35. }
  36.  
  37. i = strlen(palin);
  38.  
  39. for(cont=0;cont<i;cont++){
  40. if(palin[cont] == palin[(i-cont)-1])
  41. {
  42. cantidad = 0;
  43. } else {
  44. cantidad = 1;
  45. break;
  46. }
  47. }
  48. if(cantidad==0) {
  49. printf("La frase es palindroma.\n");
  50. } else {
  51. printf("La frase no es palindroma.\n");
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement