Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 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. printf("%d",i);
  40.  
  41. int lol=0;
  42. while (lol < 100)
  43. {
  44. printf("%c", palin[lol]);
  45. lol++;
  46. }
  47.  
  48. for(cont=0;cont<i;cont++){
  49. if(palin[cont] == palin[(i-cont)-1])
  50. {
  51. cantidad = 0;
  52. } else {
  53. cantidad = 1;
  54. break;
  55. }
  56. }
  57. if(cantidad==0) {
  58. printf("La frase es palindroma.\n");
  59. } else {
  60. printf("La frase no es palindroma.\n");
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement