Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <fstream>
- #include <string.h>
- using namespace std;
- int main()
- { int i=0,j=0,eleje=1,vege,k,h=0;
- char seg[258]=" ",s[258],ss[100][258];
- gets(s);
- strcat(seg,s);
- strcat(seg," ");
- strcpy(s,seg);
- for(i=1;s[i]!='\0';i++)
- {
- if(s[i-1]==' ' and s[i]!=' ')eleje=i;
- if(s[i]==' ' and s[i-1]!=' ')
- {
- strncpy(ss[j],s+eleje,i-eleje);
- ss[j][i-eleje]='\0';
- j++;
- }
- }
- seg[0]='\0';
- int ok=1;
- char se[258];
- while(ok==1)
- {
- ok=0;
- for(i=0;i<j-1;i++)
- if(strcmp(ss[i],ss[i+1])==1)
- { ok=1;
- strcpy(se,ss[i]);
- strcpy(ss[i],ss[i+1]);
- strcpy(ss[i+1],se);
- }
- }
- i=0;
- while(i<j-1)
- if(strcmp(ss[i],ss[i+1])==0)
- {
- for(k=i+1;k<j-1;k++)
- strcpy(ss[k],ss[k+1]);j--;
- }
- else i++;
- for(i=0;i<j;i++)
- cout<<ss[i]<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement