knyazer

Untitled

Jan 6th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void print(double x)
  6. {
  7. if (x < 0)
  8. {
  9. cout << '-';
  10. x = -x;
  11. }
  12.  
  13. cout << int(x);
  14. cout << '.';
  15. x -= int(x);
  16. x += 1e-7;
  17.  
  18. double eps = 1e-6;
  19. for (int i = 0; i < 6; i++)
  20. {
  21. eps *= 10;
  22. x *= 10;
  23. cout << int(x) % 10;
  24. x -= int(x);
  25. if (x < eps)
  26. break;
  27. }
  28.  
  29. cout << endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment