a53

joc9

a53
Feb 18th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <fstream>
  2. #include <algorithm>
  3. #define NN 40000
  4. using namespace std;
  5. int a[NN];
  6.  
  7. bool Numersum(int n)
  8. {
  9. int s=0;
  10. while(n>9)
  11. s+=n%10,n/=10;
  12. if(n==s)
  13. return true;
  14. return false;
  15. }
  16.  
  17. int main()
  18. {
  19. int n,x,N=0;
  20. ifstream f("joc.in");
  21. f>>n;
  22. while(n--)
  23. {
  24. f>>x;
  25. if(Numersum(x))
  26. a[N++]=x;
  27. }
  28. sort(a,a+N);
  29. ofstream g("joc.out");
  30. for(int i=0;i<N;++i)
  31. g<<a[i]<<' ';
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment