Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <windows.h>
- #include <locale.h>
- int main()
- {
- setlocale(LC_ALL,"Rus");
- system ("color 0A");
- char *z;
- char istr[20];
- char str[20];
- char probel [10]=" ";
- int kol_vo=0, i;
- printf ("Исходная строка:");
- char text[100];
- gets(text);
- ///Поиск слов палиндоромов и их кол-во
- z=strtok(text,probel);
- while(z!=NULL)
- {
- strcpy(istr,z);
- int sym=strlen(istr);
- for(i=0;i<sym/2+(sym%2);i++)
- {
- str[i]=istr[sym-(i+1)];
- }
- printf("\n ISTR:%10s \tSTR:%10s \tDLINNA STROKI==%d\n",istr,str,sym);
- if(strncmp(istr,str,sym/2)==0)
- {
- printf("\nСлово %s является палиндромом.\n",istr);
- kol_vo++;
- }
- /// Выделение очередной части строки
- z=strtok (NULL,probel);
- }
- printf("\n Кол-во палиндромов = %d\n",kol_vo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement