Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void print(double x)
- {
- if (x < 0)
- {
- cout << '-';
- x = -x;
- }
- cout << int(x);
- cout << '.';
- x -= int(x);
- for (int i = 0; i < 9; i++)
- {
- x *= 10;
- cout << int(x) % 10;
- if (abs(x - int(x)) < 1e-6)
- break;
- }
- cout << endl;
- }
- int main()
- {
- double n = 0;
- while (n < 2)
- {
- print(n);
- n += 0.0001;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement