From a5c1fa0e484fe209925e9f5adafc85280037676c Mon Sep 17 00:00:00 2001 From: cmirnov Date: Fri, 9 Oct 2015 11:09:27 +0300 Subject: [PATCH 1/4] Create getByte --- getByte | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 getByte diff --git a/getByte b/getByte new file mode 100644 index 0000000..5308ea6 --- /dev/null +++ b/getByte @@ -0,0 +1,13 @@ +void getByte () +{ + int a, n, cur = 255; + scanf("%d%d", &a, &n); + n += n; + n += n; + n += n; + cur = cur << n; + a = a&cur; + a = a >> n; + printf ("%d\n", a); + return; +} From ed48c60904b01b0f20f05c8658de5ec2443646c8 Mon Sep 17 00:00:00 2001 From: cmirnov Date: Fri, 23 Oct 2015 11:58:09 +0300 Subject: [PATCH 2/4] Update getByte --- getByte | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/getByte b/getByte index 5308ea6..95b276a 100644 --- a/getByte +++ b/getByte @@ -1,13 +1,10 @@ -void getByte () -{ - int a, n, cur = 255; - scanf("%d%d", &a, &n); +int getByte (int x, int n){ + int cur = 255; n += n; n += n; n += n; cur = cur << n; - a = a&cur; + a = a & cur; a = a >> n; - printf ("%d\n", a); - return; + return a; } From ea4e1b6404dbbfd169cfd25ca6bf4f335e949a16 Mon Sep 17 00:00:00 2001 From: cmirnov Date: Tue, 27 Oct 2015 15:30:51 +0300 Subject: [PATCH 3/4] Update getByte --- getByte | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/getByte b/getByte index 95b276a..3785b2b 100644 --- a/getByte +++ b/getByte @@ -1,10 +1,8 @@ int getByte (int x, int n){ int cur = 255; - n += n; - n += n; - n += n; + n *= 8; cur = cur << n; - a = a & cur; - a = a >> n; - return a; + x = x & cur; + x = x >> n; + return x; } From df739dadb6a454bd9c159df91d7008f066f7faa4 Mon Sep 17 00:00:00 2001 From: cmirnov Date: Thu, 3 Dec 2015 21:42:42 +0300 Subject: [PATCH 4/4] Update getByte --- getByte | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/getByte b/getByte index 3785b2b..6288b59 100644 --- a/getByte +++ b/getByte @@ -1,8 +1,7 @@ int getByte (int x, int n){ int cur = 255; - n *= 8; - cur = cur << n; - x = x & cur; + n = n << 3; x = x >> n; + x = x & cur; return x; }