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][20];
- int n;
- char *f(int li,int ls)
- {
- int lm;
- char *x, *y;
- if(li==ls) return v[li];
- else if(li-ls==1) {if(strlen(v[li])<strlen(v[ls])) return v[li];
- else return v[ls];}
- else
- {lm=(li+ls)/2;
- strcpy(x,f(li,lm));
- strcpy(y,f(lm+1,ls));
- if(strlen(x)<strlen(y)) return x;
- else return y;
- }
- }
- main()
- {
- int i;
- cin>>n;
- for(i=1;i<=n;i++) {
- cin.get();
- cin.get(v[i],20);}
- cout<<f(1,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement