Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- #define NN 40000
- using namespace std;
- int a[NN];
- bool Numersum(int n)
- {
- int s=0;
- while(n>9)
- s+=n%10,n/=10;
- if(n==s)
- return true;
- return false;
- }
- int main()
- {
- int n,x,N=0;
- ifstream f("joc.in");
- f>>n;
- while(n--)
- {
- f>>x;
- if(Numersum(x))
- a[N++]=x;
- }
- sort(a,a+N);
- ofstream g("joc.out");
- for(int i=0;i<N;++i)
- g<<a[i]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment