Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. setlocale(LC_ALL, "Rus");
  8. int n, l;
  9. string s;
  10. cout << " Введите десятичное число: ";
  11. cin >> n;
  12. while (n > 0)
  13. {
  14. s += n % 2 + '0';
  15. n /= 2;
  16. }
  17. l = s.length();
  18. cout << " Число в двоичной системе: ";
  19. for (int i = 0; s[i]; i++)
  20. {
  21. cout << s[l - i - 1];
  22. }
  23. cout << endl;
  24. system("pause");
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement