From 0843094b9d862f015077867263c775f4f0b3af5e Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Mon, 29 Mar 2021 01:45:30 +0200 Subject: update --- Semestr 4/ask/lista5/zad1.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Semestr 4/ask/lista5/zad1.c (limited to 'Semestr 4/ask/lista5/zad1.c') 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 +#include + +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 -- cgit v1.2.3