Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- const int nm=1e7;
- int sum(int x)
- {
- int s=0;
- while(x)
- s+=x%10,x/=10;
- return s;
- }
- int main()
- {
- int x,n=0,a[nm/10+2];
- ifstream fin("sortsum.in");
- while(fin>>x)
- a[n++]=sum(x)*nm+nm-x;
- sort(a,a+n);
- ofstream fout("sortsum.out");
- for(int i=0;i<n;++i)
- fout<<nm-a[i]%nm<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement