Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <algorithm>
  2. #include <vector>
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdlib>
  6.  
  7.  
  8. int solution(int N)
  9. {
  10. int variable;
  11. std::string temp;
  12. std::vector<int> vec_pomocniczy;
  13. std::string _str = std::to_string(N);
  14. int N_zwracane=0;
  15. if(N<100000000){
  16. for(int i=0;i<_str.size();i++)
  17. {
  18. temp=_str[i];
  19. variable = stoi( temp );
  20. vec_pomocniczy.push_back(variable);
  21. }
  22. sort(vec_pomocniczy.begin(),vec_pomocniczy.end());
  23. for(int j=0;j<vec_pomocniczy.size();j++)
  24. {
  25. N_zwracane = N_zwracane + (pow(10,j) * vec_pomocniczy[j]);
  26.  
  27. }
  28. return N_zwracane;
  29. }
  30. else
  31. {
  32. return -1;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement