Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <math.h>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <map>
- #include <sstream>
- #include <queue>
- #include <stdint.h>
- using namespace std;
- int main()
- {
- bool what = true;
- string h;
- long double dx = 0, dy = 0;
- const long double root = 0.70710678118654757;
- cin >> h;
- cout.setf(ios::fixed);
- cout.precision(10);
- for (int i = 0; i <= h.size() - 1; i++)
- {
- switch (h[i])
- {
- case '1':
- dy -= root;
- dx -= root;
- break;
- case '2':
- dy -= 1;
- break;
- case '3':
- dy -= root;
- dx += root;
- break;
- case '4':
- dx -= 1;
- break;
- case '5':
- break;
- case '6':
- dx += 1;
- break;
- case '7':
- dy += root;
- dx -= root;
- break;
- case '8':
- dy += 1;
- break;
- case '9':
- dy += root;
- dx += root;
- break;
- case '0':
- cout << dx << " " << dy;
- break;
- }
- if (h[i] == '0')
- {
- what = false;
- break;
- }
- }
- if (what == true)
- cout << dx << " " << dy;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment