Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char s[256],cuv[256][256],*p,separator[]=" ";
- cin.get(s,256);
- p=s;
- p=strtok(p,separator);
- int n=0,LitD[256];
- while(p)
- strcpy(cuv[n],p),LitD[n]=strlen(cuv[n]),++n,p=strtok(NULL,separator);
- for(int i=0;i<n-1;++i)
- for(int j=i+1;j<n;++j)
- if(LitD[i]<=LitD[j])
- {
- if(LitD[i]==LitD[j])
- {
- if(strcmp(cuv[i],cuv[j])==1)
- swap(LitD[i],LitD[j]),swap(cuv[i],cuv[j]);
- }
- else
- swap(LitD[i],LitD[j]),swap(cuv[i],cuv[j]);
- }
- for(int i=0;i<n;++i)
- cout<<cuv[i]<<'\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement