Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <alloc.h>
  4. #include <string.h>
  5. #include <conio.h>
  6. char** getxt();
  7. int zada4a(char**);
  8.  
  9. void main()
  10. {
  11. char** txt;
  12. clrscr();
  13. txt=getxt();
  14. printf("Otvet=%d\n",zada4a(txt));
  15. getch();
  16. }
  17.  
  18. char** getxt()
  19. {
  20. char **txt, buf[128]="A";
  21. int i=0,n,cht=1;
  22. txt=(char**)malloc(sizeof(char*));
  23. printf("Vvedite text:\n");
  24.     while(strlen(buf)!=0)
  25.     {
  26.     gets(buf);
  27.     n=strlen(buf);
  28.     txt[i]=(char*)malloc((n+1)*sizeof(char));
  29.     strcpy(txt[i],buf);
  30.     txt=(char**)realloc(txt,(++cht)*sizeof(char*));
  31.     i++;
  32.     }
  33. txt[i]=NULL;
  34. return txt;
  35. }
  36.  
  37. int zada4a(char** txt)
  38. {
  39. int c = 0,i=0,j,k;
  40.     while(*(txt+i))
  41.     {
  42.     j=0;
  43.         while(txt[i][j]!='\0')
  44.         {
  45.             if (isalpha(txt[i][j])==0)
  46.             {
  47.             j++;
  48.             continue;
  49.             }
  50.         k=j;
  51.             while(isalpha(txt[i][k])!=0)
  52.             {
  53.             k++;
  54.             }
  55.         if((txt[i][j]==txt[i][k-1])&&(k-j!=1)) c++;
  56.         j=k;
  57.         }
  58.     i++;
  59.     }
  60. return c;
  61. }
Add Comment
Please, Sign In to add comment