Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdlib.h>
- using namespace std;
- char v[100][15];
- char *deti(int li, int ls)
- {
- if(li==ls)
- {
- return v[li];
- }
- else if(ls-li==1)
- {
- if(strlen(v[li])<strlen(v[ls]))
- return v[li];
- else
- return v[ls];
- }
- else if(strlen(v[li])==strlen(v[ls]))
- {
- if(strcmp(v[li],v[ls])<0)
- return v[ls];
- else
- return v[li];
- }
- else
- {
- int mij;
- char *m1;
- char *m2;
- mij=(li+ls)/2;
- strcpy(m1,deti(li,mij));
- strcpy(m2,deti(mij+1,ls));
- if(strlen(m1)==strlen(m2))
- {
- if(strcmp(m1,m2)<0)
- return m2;
- else return m1;
- }
- else
- {
- if(strlen(m1)<strlen(m2))
- return m1;
- else
- return m2;
- }
- }
- }
- int main()
- {
- int k;
- cin>>k;
- for(int i=1; i<=k;i++)
- {cin.get();
- cin.get(v[i],15);}
- cout<<deti(1,k);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement