Advertisement
cupsamada

trecere din 10 in 2

Jan 27th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. long long trece( long long x10)
  4. {
  5. long long cifra, p10=1, xb=0;
  6. while(x10)
  7. {
  8. cifra=x10%2;
  9. xb=xb+cifra*p10;
  10. p10=p10*10;
  11. x10=x10/2;
  12. }
  13. return xb;
  14. }
  15. int main()
  16. {
  17. long long x, y;
  18. cin>>x;
  19. y=trece(x);
  20. cout<<y;
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement