Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void read(int& x) {
- int neg = 0; x = 0;
- char t = getchar();
- while ((t < 48 || t > 57) && t != '-') t = getchar();
- if (t == '-') { neg = 1; t = getchar(); }
- while (t >= 48 && t <= 57) {
- x = (x << 3) + (x << 1) + t - 48;
- t = getchar();
- }
- if (neg) x = -x;
- }
- void write(int x) {
- if (x == 0) { putchar('0'); return; }
- if (x < 0) { putchar('-'); x = -x; }
- char a[20]; a[0] = '0';
- int i = 0;
- while (x) {
- a[i++] = x % 10 + 48;
- x /= 10;
- }
- for (int j = i - 1; j >= 0; j--) putchar(a[j]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement