fork(1) download
  1.  
  2. //Have to work on it!!!!!!!!!!!!!!!!!!!!!//
  3. #include<stdio.h>
  4. #include<iostream>
  5. #include<string.h>
  6. using namespace std;
  7. int main()
  8. {
  9. char input[100];
  10. char modified[100]=""; //This ll be modified form only with alphabets
  11. cout<<"Enter text:\n";
  12. gets(input);
  13.  
  14. int t=strlen(input);
  15. int s=0;
  16. for(int e=0;e<t;e++)
  17. {
  18. if(islower(input[e]))
  19. {
  20. modified[s] =input[e];
  21. s++;
  22. }
  23. }
  24. printf("\nThe modified version of the text is:");
  25. puts(modified);
  26.  
  27. int l=strlen(modified);
  28. for(int a=0;a<(l-1);a++)
  29. for(int b=a+1;b<l;b++)
  30. {
  31. if(modified[a]==modified[b])
  32. {
  33. if((b-a)%2==0) //even
  34. {
  35. int x=(a+b)/2;
  36. int countt=0;
  37. for(int p=a,q=b;p<x && q>x;p++,q--)
  38. {
  39. if(modified[p]==modified[q])
  40. countt++;
  41.  
  42. else if(modified[p]!=modified[q])
  43. break;
  44.  
  45. if(countt==(b-a)/2)
  46. {
  47. cout<<"Palindrome:";
  48. for(int i=a;i<=b;i++)
  49. {
  50. putchar(modified[i]);
  51. }
  52. cout<<endl;
  53. }
  54. }
  55. }
  56.  
  57. else if((b-a)%2!=0) //odd
  58. {
  59. int y=(a+b+1)/2;
  60. int z=(a+b-1)/2;
  61. int count2=0;
  62. for(int w=a,r=b;w<y && r>z ;w++,r--)
  63. {
  64. if(modified[w]==modified[r])
  65. count2++;
  66.  
  67. else if(modified[w]!=modified[r])
  68. break;
  69.  
  70. if(count2==(b-a+1)/2)
  71. {
  72. cout<<"Palindrome:";
  73. for(int o=a;o<=b;o++)
  74. {
  75. putchar(modified[o]);
  76. }
  77. cout<<endl;
  78. }
  79. }
  80. }
  81. }
  82. }
  83. }
  84.  
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
Enter text:

The modified version of the text is:y