Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <deque>
- #include <algorithm>
- using namespace std;
- int Raspon (const int &n)
- { int pom{n};
- int max{pom%10}, min{pom%10};
- pom/=10;
- while (pom!=0) {
- if (pom%10>max) max=pom%10;
- if (pom%10<min) min=pom%10;
- pom/=10;
- }
- return max-min;
- }
- int main () {
- deque <int> dek(3);
- cout<<"Unesite elemente deka: ";
- for (int i=0; i<3; i++) cin>>dek[i];
- sort(dek.begin(), dek.end(), [] (int x, int y) {if (Raspon(x)==Raspon(y)) return x>y; else return Raspon(x)>Raspon(y);});
- cout<<"Sortirano: ";
- for (auto x: dek) cout<<x<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement