CristinaGeorgiu

multiple si nemultiple de 3

Nov 18th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,x,r,p,r1,p1;
  6. cin>>n;
  7. p=1;
  8. p1=1;
  9. r=0;
  10. r1=0;
  11. while(n!=0)
  12. {
  13. x=n%10;
  14. if(x%3==0&&x!=0)
  15. {
  16. r=r+x*p;
  17. p=p*10;
  18. }
  19. else
  20. {
  21. r1=r1+x*p1;
  22. p1=p1*10;
  23. }
  24. n=n/10;
  25. }
  26. cout<<r<<" "<<r1;
  27. return 0;
  28. }
Add Comment
Please, Sign In to add comment