Advertisement
rofllmaolol

problema1

Jan 29th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdlib.h>
  4. using namespace std;
  5. char v[100][20];
  6. int n;
  7. char *f(int li,int ls)
  8. {
  9. int lm;
  10. char *x, *y;
  11. if(li==ls) return v[li];
  12. else if(li-ls==1) {if(strlen(v[li])<strlen(v[ls])) return v[li];
  13.                                             else return v[ls];}
  14. else
  15. {lm=(li+ls)/2;
  16. strcpy(x,f(li,lm));
  17. strcpy(y,f(lm+1,ls));
  18. if(strlen(x)<strlen(y)) return x;
  19. else return y;
  20.  
  21. }
  22. }
  23. main()
  24. {
  25. int i;
  26. cin>>n;
  27. for(i=1;i<=n;i++) {
  28.     cin.get();
  29. cin.get(v[i],20);}
  30. cout<<f(1,n);
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement