Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct word {char *str;
- int count;
- struct word *next;
- }*first=NULL,kol;
- int main()
- {
- void output(void);
- void copy_next(int ,char []);
- int i=0;
- char buf[2048];
- struct word *q;
- kol.count=0;
- while((buf[i]=getchar())!=EOF)
- {
- if((buf[i]<='z' && buf[i]>='a')||(buf[i]>='A' && buf[i]<='Z'))
- {
- i++;
- }
- if(((buf[i]==' ')||(buf[i]=='\t')||(buf[i]=='\n'))&&(i!=0))
- {
- buf[i]='\0';
- i=0;
- copy_next(i,buf);
- }
- }
- printf("\n");
- while(first)
- {
- output();
- }
- }
- void output(void)
- {
- struct word *q;
- if(kol.count==0)
- {
- printf("%s ",first->str);
- printf("%d\n",kol.count);
- }
- q=first;
- first=first->next;
- free(q->str);
- free(q);
- }
- void copy_next(int i,char buf[])
- {
- char* r;
- struct word *q;
- struct word *r2;
- struct word *first1;
- struct word kol2;
- int k=0;
- first1=first;
- r=(char*)malloc(i);
- if(r==NULL)
- {
- exit(1);
- }
- if((r2=(struct word *)malloc(sizeof(struct word)))==NULL)
- {
- exit (1);
- }
- strcpy(r,buf);
- while(first1)
- {
- if(r2->str==r)
- {
- kol2.count=k+1;
- free(r);
- }
- q=first1;
- first1=first1->next;
- }
- r2->str=r;
- q=first;
- first=r2;
- r2->next=q;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement