Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <alloc.h>
- #include <string.h>
- #include <conio.h>
- char** getxt();
- int zada4a(char**);
- void main()
- {
- char** txt;
- clrscr();
- txt=getxt();
- printf("Otvet=%d\n",zada4a(txt));
- getch();
- }
- char** getxt()
- {
- char **txt, buf[128]="A";
- int i=0,n,cht=1;
- txt=(char**)malloc(sizeof(char*));
- printf("Vvedite text:\n");
- while(strlen(buf)!=0)
- {
- gets(buf);
- n=strlen(buf);
- txt[i]=(char*)malloc((n+1)*sizeof(char));
- strcpy(txt[i],buf);
- txt=(char**)realloc(txt,(++cht)*sizeof(char*));
- i++;
- }
- txt[i]=NULL;
- return txt;
- }
- int zada4a(char** txt)
- {
- int c = 0,i=0,j,k;
- while(*(txt+i))
- {
- j=0;
- while(txt[i][j]!='\0')
- {
- if (isalpha(txt[i][j])==0)
- {
- j++;
- continue;
- }
- k=j;
- while(isalpha(txt[i][k])!=0)
- {
- k++;
- }
- if((txt[i][j]==txt[i][k-1])&&(k-j!=1)) c++;
- j=k;
- }
- i++;
- }
- return c;
- }
Add Comment
Please, Sign In to add comment