Guest User

Untitled

a guest
May 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define S 256
  5.  
  6. int isPalyndrom( char s[S])
  7. {
  8. int i;
  9. int check=0;
  10. int c1=0;
  11.  
  12. while (s[check] !='\0')
  13. check++;
  14. for (i=0;i<check;i++)
  15. {
  16. int j=check-1;
  17. if (s[i]==s[j])
  18. {
  19. check--;
  20. }
  21. else
  22. {
  23. c1=0;
  24. break;
  25. }
  26. c1++;
  27. }
  28. if (c1>0)
  29. printf("\n\n%s is a Palina(?)drom \n",s);
  30. else
  31. printf("\n\n%s is No_0T a Palina(?)drom \n",s);
  32. return (0);
  33. }
  34. void SwitchLetters( char s[S])
  35. {
  36. int i,j,temp;
  37. int check=0;
  38.  
  39. //size of actual sing
  40. while (s[check] !='\0')
  41. check++;
  42.  
  43. //checking of the sing
  44. for(i=0,j=1; i < check ; i++,j++)
  45. {
  46. {
  47. if(s[j] == s[i]+1)
  48. {
  49. temp = s[i];
  50. s[i] = s[j];
  51. s[j] = temp;
  52. }
  53. }
  54. if (check-i==1)
  55. break;
  56. }
  57. printf("%s\n",s);
  58. }
  59.  
  60. void main()
  61. {
  62. char s[S];
  63.  
  64. printf("\n\n---*Enter jibrish*---\n");
  65. gets (s);
  66.  
  67. s[S]=isPalyndrom(s);
  68. SwitchLetters(s);
  69. /*void RemoveChar (char s[S], char ch);
  70. int ss( char s1[S] , char s2[S] );
  71. int sing2Integer (char s[S]);
  72. */
  73. }
Add Comment
Please, Sign In to add comment