Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5. #include <locale.h>
  6.  
  7. int main()
  8. {
  9. setlocale(LC_ALL,"Rus");
  10. system ("color 0A");
  11. char *z;
  12. char istr[20];
  13. char str[20];
  14. char probel [10]=" ";
  15. int kol_vo=0, i;
  16. printf ("Исходная строка:");
  17. char text[100];
  18. gets(text);
  19. ///Поиск слов палиндоромов и их кол-во
  20. z=strtok(text,probel);
  21. while(z!=NULL)
  22. {
  23. strcpy(istr,z);
  24.  
  25. int sym=strlen(istr);
  26. for(i=0;i<sym/2+(sym%2);i++)
  27. {
  28. str[i]=istr[sym-(i+1)];
  29. }
  30. printf("\n ISTR:%10s \tSTR:%10s \tDLINNA STROKI==%d\n",istr,str,sym);
  31. if(strncmp(istr,str,sym/2)==0)
  32. {
  33. printf("\nСлово %s является палиндромом.\n",istr);
  34. kol_vo++;
  35. }
  36. /// Выделение очередной части строки
  37. z=strtok (NULL,probel);
  38. }
  39. printf("\n Кол-во палиндромов = %d\n",kol_vo);
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement