#include <vector> #include <string> #include <iostream> #include <algorithm> using namespace std; bool compare(string prev, string next) { int lpos = 0, rpos= 0; while (lpos < prev.length() && rpos < next.length()) { if (prev[lpos] > next[rpos]) return true; else if (prev[lpos] < prev[rpos]) return false; lpos++; rpos++; } if (rpos < next.length()) return ( prev[lpos-1] > next[rpos]); else if (lpos< prev.length()) return (prev[lpos] > next[rpos-1]); return true; } string produce_biggest_number(vector<string> & input) { string result =""; sort(input.begin(), input.end(), compare); for (int i =0; i< input.size(); i++) { cout <<input[i]<<endl; result += input[i]; } return result; } int main () { vector<string> input; input.push_back("1000"); input.push_back("898"); input.push_back("77"); input.push_back("55"); input.push_back("8989"); cout<<compare("898", "8989")<<endl; cout<<"biggest number is = "<<produce_biggest_number(input)<<endl; }