diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-10-05 21:49:54 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-10-05 21:49:54 +0200 |
commit | c5fcf7179a83ef65c86c6a4a390029149e518649 (patch) | |
tree | d29ffc5b86a0d257453cedcf87d91a13d8bf3b0d /Semestr 4/ask/lista5/zad4.c | |
parent | f8a88b6a4aba1f66d04711a9330eaba49a50c463 (diff) |
Duzy commit ze smieciami
Diffstat (limited to 'Semestr 4/ask/lista5/zad4.c')
-rw-r--r-- | Semestr 4/ask/lista5/zad4.c | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/Semestr 4/ask/lista5/zad4.c b/Semestr 4/ask/lista5/zad4.c deleted file mode 100644 index a6927fb..0000000 --- a/Semestr 4/ask/lista5/zad4.c +++ /dev/null @@ -1,66 +0,0 @@ -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> - -int puzzle4(long *a, long v, uint64_t s, uint64_t e); - -long tab[100]; - -int assembly_like(long *rdi, long rsi, uint64_t rdx, uint64_t rcx) { - uint64_t rax = rcx; - rax -= rdx; - rax >>= 1; - rax += rdx; - if (rcx < rdx) { - goto L5; - } - long r8 = *(rdi + rax*8); - if (rsi == r8) { - goto L10; - } - if (rsi > r8) { - goto L11; - } - rdx = rax + 1; - assembly_like(rdi, rsi, rdx, rcx); -L10: - return (int)rax; -L11: - rcx = rax - 1; - assembly_like(rdi, rsi, rdx, rcx); - return (int)rax; -L5: - return -1; -} - - -// binsearch :) -int decode(long *a, long v, uint64_t s, uint64_t e) { - int result = (e + s) / 2; - if (e < s) { - return -1; - } - long val = a[result]; - if (v == val) { - return result; - } - if (v < val) { - e = result - 1; - } - else { - s = result + 1; - } - return decode(a, v, s, e); -} - -int main() { - uint64_t n; - long v; - scanf("%ld %ld", &n, &v); - for (int i = 0; i < n; i++) { - scanf("%ld", &tab[i]); - } - printf("%d\n", puzzle4(tab, v, 0, n-1)); - printf("%d\n", decode(tab, v, 0, n-1)); - -}
\ No newline at end of file |