Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <vector>
- #include <iostream>
- #include <string>
- #include <cstdlib>
- int solution(int N)
- {
- int variable;
- std::string temp;
- std::vector<int> vec_pomocniczy;
- std::string _str = std::to_string(N);
- int N_zwracane=0;
- if(N<100000000){
- for(int i=0;i<_str.size();i++)
- {
- temp=_str[i];
- variable = stoi( temp );
- vec_pomocniczy.push_back(variable);
- }
- sort(vec_pomocniczy.begin(),vec_pomocniczy.end());
- for(int j=0;j<vec_pomocniczy.size();j++)
- {
- N_zwracane = N_zwracane + (pow(10,j) * vec_pomocniczy[j]);
- }
- return N_zwracane;
- }
- else
- {
- return -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement