diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-03-29 01:45:30 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-03-29 01:45:30 +0200 |
commit | 0843094b9d862f015077867263c775f4f0b3af5e (patch) | |
tree | 27cccc81cac833bbd7c74beb0e9256ad8a4d0153 /Semestr 4/ask/lista5/zad1.c | |
parent | efca1869bbb5d3a7764d6e8be406246a09cd0634 (diff) |
update
Diffstat (limited to 'Semestr 4/ask/lista5/zad1.c')
-rw-r--r-- | Semestr 4/ask/lista5/zad1.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Semestr 4/ask/lista5/zad1.c b/Semestr 4/ask/lista5/zad1.c new file mode 100644 index 0000000..9379bb2 --- /dev/null +++ b/Semestr 4/ask/lista5/zad1.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <stdint.h> + +int puzzle(long x /* rdi */ , unsigned n /* rsi */) { + if (n == 0) { + return n; + } + int t = 0; // edx := 0 + int result = 0; // eax := 0 + do { + int m = x & 0xffffffff; // ecx := edi + m &= 1; + result += m; + x >>= 1; + t++; + } while (t != n); + return result; // ???? +} + +int main() { + long x; + unsigned n; + scanf("%ld%u", &x, &n); + return puzzle(x, n); +}
\ No newline at end of file |