Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /*
  6. Goal is to have all the shorter strings before the larger strings.
  7. Otherwise if the two strings are equal compare the string that comes first in alphabetical order
  8. */
  9.  
  10. bool stringcomparator(string a, string b){ //returns true if a goes before b.
  11. if(a.size() == b.size()){
  12. for(int i = 0; i<a.size(); i++){
  13. if(a[i] != b[i]){
  14. return a[i] < b[i];
  15. }
  16. }
  17. return false;
  18. }
  19. else{
  20. return a.size() < b.size();
  21. }
  22. }
  23.  
  24. int main(){
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement