From c5fcf7179a83ef65c86c6a4a390029149e518649 Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Tue, 5 Oct 2021 21:49:54 +0200 Subject: Duzy commit ze smieciami --- Semestr 4/aisd/lista0/L0Z8.md | 51 - Semestr 4/aisd/lista0/Rozw L0.pdf | Bin 1983735 -> 0 bytes Semestr 4/aisd/lista0/lista0.pdf | Bin 83161 -> 0 bytes Semestr 4/aisd/lista1/Lista 1.pdf | Bin 810791 -> 0 bytes Semestr 4/aisd/lista1/lista1.pdf | Bin 103432 -> 0 bytes Semestr 4/aisd/lista2/Lista 2.pdf | Bin 2301798 -> 0 bytes Semestr 4/aisd/lista2/lista2.pdf | Bin 128638 -> 0 bytes Semestr 4/aisd/lista3/huff.pdf | Bin 62844 -> 0 bytes Semestr 4/aisd/lista3/huffman.pdf | Bin 73477 -> 0 bytes Semestr 4/aisd/lista3/lista3.pdf | Bin 179499 -> 0 bytes Semestr 4/aisd/pracownia1/pracownia1.pdf | Bin 55846 -> 0 bytes Semestr 4/aisd/pracownia1/rozw.cpp | 59 - Semestr 4/aisd/pracownia1/rozw2.cpp | 33 - Semestr 4/aisd/pracownia2/gen.py | 24 - Semestr 4/aisd/pracownia2/gen_test.sh | 24 - Semestr 4/aisd/pracownia2/rozw.cpp | 59 - Semestr 4/aisd/pracownia2/rozw2.cpp | 71 - Semestr 4/aisd/pracownia2/rozw3.cpp | 71 - Semestr 4/aisd/pracownia2/rozw4.cpp | 51 - Semestr 4/aisd/pracownia2/show_problem.pdf | Bin 53598 -> 0 bytes Semestr 4/aisd/pracownia3/check.cpp | 87 - Semestr 4/aisd/pracownia3/gen.py | 14 - Semestr 4/aisd/pracownia3/ocen.sh | 18 - Semestr 4/aisd/pracownia3/rozw.cpp | 102 - Semestr 4/aisd/pracownia3/show_problem.pdf | Bin 73936 -> 0 bytes Semestr 4/aisd/pracownia3/wa.outr | 1025 ----- Semestr 4/aisd/pracownia4/brut.cpp | 69 - Semestr 4/aisd/pracownia4/gen.py | 24 - Semestr 4/aisd/pracownia4/rozw.cpp | 157 - Semestr 4/aisd/pracownia4/rozw2.cpp | 135 - Semestr 4/aisd/pracownia4/rozw3.cpp | 149 - Semestr 4/aisd/pracownia4/show_problem.pdf | Bin 61345 -> 0 bytes Semestr 4/aisd/pracownia4/test.sh | 21 - Semestr 4/aisd/pracownia5/gen.py | 40 - Semestr 4/aisd/pracownia5/wzo.cpp | 286 -- Semestr 4/aisd/pracownia5/wzo2.cpp | 184 - Semestr 4/aisd/pracownia6/wzo.cpp | 51 - Semestr 4/aisd/themis/AISDDEBIUT21.cpp | 24 - Semestr 4/aisd/themis/AISDPOTEGOWANIE.cpp | 29 - Semestr 4/aisd/themis/BELLMAN.cpp | 55 - Semestr 4/aisd/themis/FIB.cpp | 58 - .../aisd/wyklady/Notatka 1 - Preliminaria.pdf | Bin 211162 -> 0 bytes Semestr 4/aisd/wyklady/Notatka 2 - Kopiec.pdf | Bin 150213 -> 0 bytes .../aisd/wyklady/Notatka 3 - Zach\305\202any.pdf" | Bin 243598 -> 0 bytes .../wyklady/Notatka 4 - divide and conquer.pdf | Bin 326839 -> 0 bytes .../wyklady/Notatka 5 - divide and conquer cd.pdf | Bin 146884 -> 0 bytes .../Notatka 6 - Programowanie Dynamiczne.pdf | Bin 213697 -> 0 bytes .../Notatka 7 - Programowanie Dynamiczne cd.pdf | Bin 214965 -> 0 bytes Semestr 4/ask/lista0/Lista 0.pdf | Bin 362255 -> 0 bytes Semestr 4/ask/lista0/ask21_lista_0.pdf | Bin 94705 -> 0 bytes Semestr 4/ask/lista0/rozw.c | 78 - Semestr 4/ask/lista1/ask21_lista_1.pdf | Bin 118889 -> 0 bytes Semestr 4/ask/lista1/rozw.c | 217 - Semestr 4/ask/lista1/test.c | 11 - Semestr 4/ask/lista1/zad7.txt | 21 - Semestr 4/ask/lista11/gen.py | 65 - Semestr 4/ask/lista11/zad8.c | 23 - Semestr 4/ask/lista2/ask21_lista_2.pdf | Bin 137597 -> 0 bytes Semestr 4/ask/lista2/pom.c | 38 - Semestr 4/ask/lista3/ask21_lista_3.pdf | Bin 152374 -> 0 bytes Semestr 4/ask/lista4/ask21_lista_4.pdf | Bin 149361 -> 0 bytes Semestr 4/ask/lista5/ask21_lista_5.pdf | Bin 91135 -> 0 bytes Semestr 4/ask/lista5/puzzle3.s | 19 - Semestr 4/ask/lista5/puzzle4.s | 24 - Semestr 4/ask/lista5/puzzle5.s | 24 - Semestr 4/ask/lista5/zad1.asm | 15 - Semestr 4/ask/lista5/zad1.c | 25 - Semestr 4/ask/lista5/zad1.s | 98 - Semestr 4/ask/lista5/zad2.asm | 15 - Semestr 4/ask/lista5/zad2.c | 44 - Semestr 4/ask/lista5/zad3.c | 60 - Semestr 4/ask/lista5/zad4.c | 66 - Semestr 4/ask/lista5/zad5.c | 54 - Semestr 4/ask/lista6/puzzle.c | 28 - Semestr 4/ask/lista6/puzzle.s | 22 - Semestr 4/ask/lista6/puzzle7.s | 29 - Semestr 4/ask/lista6/puzzle8.c | 25 - Semestr 4/ask/lista6/puzzle8.s | 30 - Semestr 4/ask/lista6/test.c | 9 - Semestr 4/ask/lista6/zad7.c | 18 - Semestr 4/ask/lista7/eval.s | 18 - Semestr 4/ask/lista7/wrap.s | 18 - Semestr 4/ask/lista7/zad5.c | 38 - Semestr 4/ask/lista7/zad5.s | 0 Semestr 4/ask/lista7/zad7.cpp | 19 - Semestr 4/ask/lista7/zad7.ll | 174 - Semestr 4/ask/lista8/._lista_8 | Bin 212 -> 0 bytes Semestr 4/ask/lista8/ask21_lista_8.tgz | Bin 2136 -> 0 bytes Semestr 4/ask/lista8/bar.c | 5 - Semestr 4/ask/lista8/even.c | 8 - Semestr 4/ask/lista8/foo.c | 5 - Semestr 4/ask/lista8/lazy.c | 7 - Semestr 4/ask/lista8/main.lds | 39 - Semestr 4/ask/lista8/merge-1.map | 300 -- Semestr 4/ask/lista8/merge-2.map | 301 -- Semestr 4/ask/lista8/mismatch-a.c | 7 - Semestr 4/ask/lista8/mismatch-b.c | 8 - Semestr 4/ask/lista8/odd.c | 8 - Semestr 4/ask/lista8/relo3.c | 15 - Semestr 4/ask/lista8/start.c | 8 - Semestr 4/ask/lista8/str-a.c | 10 - Semestr 4/ask/lista8/str-b.c | 9 - Semestr 4/ask/lista8/swap.c | 18 - Semestr 4/ask/lista9/gadget.s | 16 - Semestr 4/ask/lista9/lazy.c | 7 - Semestr 4/ask/lista9/lista_9.tgz | Bin 1278 -> 0 bytes Semestr 4/ask/lista9/relo3.c | 15 - Semestr 4/ask/lista9/ropex.c | 31 - Semestr 4/ask/lista9/ropex.in (1).txt | 7 - Semestr 4/ask/lista9/ropex.in.txt | 7 - Semestr 4/ask/lista9/ropex.map | 511 --- Semestr 4/ask/lista9/test.c | 7 - Semestr 4/ask/lista9/test.s | 50 - .../materia\305\202y/ask21-05-machine-basics.pdf" | Bin 930028 -> 0 bytes .../materia\305\202y/ask21-06-machine-control.pdf" | Bin 1673505 -> 0 bytes .../ask21-07-machine-procedures.pdf" | Bin 1096679 -> 0 bytes .../ask/materia\305\202y/hackersdelight.pdf" | Bin 25678006 -> 0 bytes .../ask/materia\305\202y/x64_cheatsheet.pdf" | Bin 192472 -> 0 bytes .../ask/materia\305\202y/x86-64-psABI-1.0.pdf" | Bin 496280 -> 0 bytes Semestr 4/ask/zadanie1/rozw.c | 21 - .../pstwo/kol1/FranciszekMalinkaKolokwium1.pdf | Bin 3170096 -> 0 bytes Semestr 4/pstwo/lista1/L1Z4.pdf | Bin 413391 -> 0 bytes Semestr 4/pstwo/lista1/RP1R_01.pdf | Bin 124161 -> 0 bytes Semestr 4/pstwo/lista10/L10.pdf | Bin 460855 -> 0 bytes Semestr 4/pstwo/lista10/RP1R_10.pdf | Bin 168326 -> 0 bytes Semestr 4/pstwo/lista2/L2Z11.pdf | Bin 409088 -> 0 bytes Semestr 4/pstwo/lista2/RP1R_02.pdf | Bin 135145 -> 0 bytes Semestr 4/pstwo/lista3/L3Z4.pdf | Bin 1548668 -> 0 bytes Semestr 4/pstwo/lista3/RP1R_03.pdf | Bin 122308 -> 0 bytes Semestr 4/pstwo/lista4/L4Z15.pdf | Bin 781525 -> 0 bytes Semestr 4/pstwo/lista4/RP1R_04.pdf | Bin 125285 -> 0 bytes Semestr 4/pstwo/lista5/L5Z12.pdf | Bin 341917 -> 0 bytes Semestr 4/pstwo/lista5/RP1R_05.pdf | Bin 145087 -> 0 bytes Semestr 4/pstwo/lista6/L6Z13.pdf | Bin 3570523 -> 0 bytes Semestr 4/pstwo/lista6/RP1R_06.pdf | Bin 105825 -> 0 bytes Semestr 4/pstwo/lista7/RP1R_07.pdf | Bin 120789 -> 0 bytes Semestr 4/pstwo/lista8/RP1R_08.pdf | Bin 139241 -> 0 bytes Semestr 4/pstwo/lista9/RP1R_09.pdf | Bin 148428 -> 0 bytes Semestr 4/pstwo/lista9/l9z3.pdf | Bin 214513 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 10.pdf | Bin 2501929 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 11.pdf | Bin 2046767 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 12.pdf | Bin 1949522 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 2.pdf | Bin 3943486 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 3.pdf | Bin 2970744 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 4.pdf | Bin 3276716 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 5.pdf | Bin 2956199 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 7.pdf | Bin 2275376 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 8.pdf | Bin 2762167 -> 0 bytes Semestr 4/pstwo/wyklady/Wyklad 9.pdf | Bin 2971703 -> 0 bytes "Semestr 4/pstwo/wyklady/Wyk\305\202ad 1.pdf" | Bin 1673358 -> 0 bytes "Semestr 4/pstwo/wyklady/Wyk\305\202ad 6.pdf" | Bin 2823651 -> 0 bytes Semestr 4/pstwo/wyklady/w1.svg | 4229 -------------------- Semestr 4/rr1r/kol1/kol1.xopp | Bin 890 -> 0 bytes Semestr 4/rr1r/kol1/zad1.pdf | Bin 510360 -> 0 bytes Semestr 4/rr1r/kol1/zad2.pdf | Bin 620724 -> 0 bytes Semestr 4/rr1r/kol1/zad3.pdf | Bin 658285 -> 0 bytes Semestr 4/rr1r/lista1/L1Z3.pdf | Bin 1210433 -> 0 bytes Semestr 4/rr1r/lista1/RR1R-01.pdf | Bin 100982 -> 0 bytes Semestr 4/rr1r/lista2/L2Z4.pdf | Bin 137162 -> 0 bytes Semestr 4/rr1r/lista2/L2Z9.pdf | Bin 378611 -> 0 bytes Semestr 4/rr1r/lista2/RR1R-02.pdf | Bin 100435 -> 0 bytes Semestr 4/rr1r/lista3/RR1R-03.pdf | Bin 90514 -> 0 bytes Semestr 4/rr1r/lista4/RR1R-04.pdf | Bin 137777 -> 0 bytes Semestr 4/rr1r/lista5/RR1R-05.pdf | Bin 99963 -> 0 bytes Semestr 4/rr1r/lista6/RR1R-06.pdf | Bin 120530 -> 0 bytes Semestr 4/rr1r/lista7/RR1R-07.pdf | Bin 85380 -> 0 bytes Semestr 4/rr1r/lista8/L8.pdf | Bin 1064722 -> 0 bytes Semestr 4/rr1r/lista8/RR1R-08.pdf | Bin 94183 -> 0 bytes Semestr 4/rr1r/lista9/RR1R-09.pdf | Bin 99502 -> 0 bytes Semestr 4/sieci/cwiczenia1/c1.pdf | Bin 164919 -> 0 bytes Semestr 4/sieci/cwiczenia1/cw1.pdf | Bin 1647345 -> 0 bytes Semestr 4/sieci/cwiczenia1/out.pdf | Bin 1613073 -> 0 bytes Semestr 4/sieci/cwiczenia1/rozw.pdf | Bin 26846 -> 0 bytes Semestr 4/sieci/cwiczenia2/c2.pdf | Bin 179367 -> 0 bytes Semestr 4/sieci/pracownia1/makefile | 19 - Semestr 4/sieci/pracownia1/p1.pdf | Bin 79285 -> 0 bytes Semestr 4/sieci/pracownia1/traceroute.c | 240 -- .../sieci/pracownia2/franciszek_malinka.tar.xz | Bin 6012 -> 0 bytes .../sieci/pracownia2/franciszek_malinka/config.h | 15 - .../pracownia2/franciszek_malinka/dist_vector.c | 114 - .../pracownia2/franciszek_malinka/dist_vector.h | 36 - .../pracownia2/franciszek_malinka/linked_list.c | 79 - .../pracownia2/franciszek_malinka/linked_list.h | 42 - .../sieci/pracownia2/franciszek_malinka/makefile | 34 - .../pracownia2/franciszek_malinka/network_addr.c | 65 - .../pracownia2/franciszek_malinka/network_addr.h | 28 - .../sieci/pracownia2/franciszek_malinka/router.c | 60 - .../sieci/pracownia2/franciszek_malinka/test.c | 52 - .../sieci/pracownia2/franciszek_malinka/utils.c | 208 - .../sieci/pracownia2/franciszek_malinka/utils.h | 52 - Semestr 4/sieci/pracownia2/p2.pdf | Bin 98190 -> 0 bytes Semestr 4/sieci/pracownia2/router/config.h | 15 - Semestr 4/sieci/pracownia2/router/dist_vector.c | 114 - Semestr 4/sieci/pracownia2/router/dist_vector.h | 36 - Semestr 4/sieci/pracownia2/router/linked_list.c | 79 - Semestr 4/sieci/pracownia2/router/linked_list.h | 42 - Semestr 4/sieci/pracownia2/router/makefile | 34 - Semestr 4/sieci/pracownia2/router/network_addr.c | 65 - Semestr 4/sieci/pracownia2/router/network_addr.h | 28 - Semestr 4/sieci/pracownia2/router/router.c | 60 - Semestr 4/sieci/pracownia2/router/test.c | 52 - Semestr 4/sieci/pracownia2/router/utils.c | 208 - Semestr 4/sieci/pracownia2/router/utils.h | 52 - Semestr 4/sieci/pracownia2/udp_client.c | 41 - Semestr 4/sieci/pracownia2/udp_server.c | 59 - Semestr 4/sieci/pracownia3/config.h | 10 - Semestr 4/sieci/pracownia3/p3.pdf | Bin 95110 -> 0 bytes Semestr 4/sieci/pracownia3/transport.c | 149 - Semestr 4/sieci/pracownia3/utils.c | 58 - Semestr 4/sieci/pracownia3/utils.h | 18 - Semestr 4/sieci/pracownia3/window.c | 42 - Semestr 4/sieci/pracownia3/window.h | 24 - Semestr 4/sieci/pracownia4/p4.pdf | Bin 151294 -> 0 bytes Semestr 4/sieci/warsztaty1/w1.pdf | Bin 93952 -> 0 bytes Semestr 4/sieci/warsztaty2/w2.pdf | Bin 190886 -> 0 bytes Semestr 4/sieci/warsztaty3/w3.pdf | Bin 112755 -> 0 bytes Semestr 4/sieci/warsztaty4/w4.pdf | Bin 210974 -> 0 bytes Semestr 4/sieci/warsztaty5/w5.pdf | Bin 121273 -> 0 bytes Semestr 4/sieci/warsztaty6/w6.pdf | Bin 75165 -> 0 bytes Semestr 4/sieci/wyklady/lec1.pdf | Bin 8280250 -> 0 bytes Semestr 4/sieci/wyklady/lec2.pdf | Bin 5058364 -> 0 bytes Semestr 4/sieci/wyklady/lec3.pdf | Bin 8701267 -> 0 bytes Semestr 4/sieci/wyklady/lec4.pdf | Bin 5658130 -> 0 bytes Semestr 4/sieci/wyklady/lec5.pdf | Bin 4572488 -> 0 bytes Semestr 4/sieci/wyklady/lec6.pdf | Bin 3339096 -> 0 bytes Semestr 4/sieci/wyklady/lec7.pdf | Bin 1825393 -> 0 bytes Semestr 4/sieci/wyklady/lec8.pdf | Bin 2144653 -> 0 bytes 227 files changed, 12175 deletions(-) delete mode 100644 Semestr 4/aisd/lista0/L0Z8.md delete mode 100644 Semestr 4/aisd/lista0/Rozw L0.pdf delete mode 100644 Semestr 4/aisd/lista0/lista0.pdf delete mode 100644 Semestr 4/aisd/lista1/Lista 1.pdf delete mode 100644 Semestr 4/aisd/lista1/lista1.pdf delete mode 100644 Semestr 4/aisd/lista2/Lista 2.pdf delete mode 100644 Semestr 4/aisd/lista2/lista2.pdf delete mode 100644 Semestr 4/aisd/lista3/huff.pdf delete mode 100644 Semestr 4/aisd/lista3/huffman.pdf delete mode 100644 Semestr 4/aisd/lista3/lista3.pdf delete mode 100644 Semestr 4/aisd/pracownia1/pracownia1.pdf delete mode 100644 Semestr 4/aisd/pracownia1/rozw.cpp delete mode 100644 Semestr 4/aisd/pracownia1/rozw2.cpp delete mode 100644 Semestr 4/aisd/pracownia2/gen.py delete mode 100755 Semestr 4/aisd/pracownia2/gen_test.sh delete mode 100644 Semestr 4/aisd/pracownia2/rozw.cpp delete mode 100644 Semestr 4/aisd/pracownia2/rozw2.cpp delete mode 100644 Semestr 4/aisd/pracownia2/rozw3.cpp delete mode 100644 Semestr 4/aisd/pracownia2/rozw4.cpp delete mode 100644 Semestr 4/aisd/pracownia2/show_problem.pdf delete mode 100644 Semestr 4/aisd/pracownia3/check.cpp delete mode 100644 Semestr 4/aisd/pracownia3/gen.py delete mode 100755 Semestr 4/aisd/pracownia3/ocen.sh delete mode 100644 Semestr 4/aisd/pracownia3/rozw.cpp delete mode 100644 Semestr 4/aisd/pracownia3/show_problem.pdf delete mode 100644 Semestr 4/aisd/pracownia3/wa.outr delete mode 100644 Semestr 4/aisd/pracownia4/brut.cpp delete mode 100644 Semestr 4/aisd/pracownia4/gen.py delete mode 100644 Semestr 4/aisd/pracownia4/rozw.cpp delete mode 100644 Semestr 4/aisd/pracownia4/rozw2.cpp delete mode 100644 Semestr 4/aisd/pracownia4/rozw3.cpp delete mode 100644 Semestr 4/aisd/pracownia4/show_problem.pdf delete mode 100755 Semestr 4/aisd/pracownia4/test.sh delete mode 100644 Semestr 4/aisd/pracownia5/gen.py delete mode 100644 Semestr 4/aisd/pracownia5/wzo.cpp delete mode 100644 Semestr 4/aisd/pracownia5/wzo2.cpp delete mode 100644 Semestr 4/aisd/pracownia6/wzo.cpp delete mode 100644 Semestr 4/aisd/themis/AISDDEBIUT21.cpp delete mode 100644 Semestr 4/aisd/themis/AISDPOTEGOWANIE.cpp delete mode 100644 Semestr 4/aisd/themis/BELLMAN.cpp delete mode 100644 Semestr 4/aisd/themis/FIB.cpp delete mode 100644 Semestr 4/aisd/wyklady/Notatka 1 - Preliminaria.pdf delete mode 100644 Semestr 4/aisd/wyklady/Notatka 2 - Kopiec.pdf delete mode 100644 "Semestr 4/aisd/wyklady/Notatka 3 - Zach\305\202any.pdf" delete mode 100644 Semestr 4/aisd/wyklady/Notatka 4 - divide and conquer.pdf delete mode 100644 Semestr 4/aisd/wyklady/Notatka 5 - divide and conquer cd.pdf delete mode 100644 Semestr 4/aisd/wyklady/Notatka 6 - Programowanie Dynamiczne.pdf delete mode 100644 Semestr 4/aisd/wyklady/Notatka 7 - Programowanie Dynamiczne cd.pdf delete mode 100644 Semestr 4/ask/lista0/Lista 0.pdf delete mode 100644 Semestr 4/ask/lista0/ask21_lista_0.pdf delete mode 100644 Semestr 4/ask/lista0/rozw.c delete mode 100644 Semestr 4/ask/lista1/ask21_lista_1.pdf delete mode 100644 Semestr 4/ask/lista1/rozw.c delete mode 100644 Semestr 4/ask/lista1/test.c delete mode 100644 Semestr 4/ask/lista1/zad7.txt delete mode 100644 Semestr 4/ask/lista11/gen.py delete mode 100644 Semestr 4/ask/lista11/zad8.c delete mode 100644 Semestr 4/ask/lista2/ask21_lista_2.pdf delete mode 100644 Semestr 4/ask/lista2/pom.c delete mode 100644 Semestr 4/ask/lista3/ask21_lista_3.pdf delete mode 100644 Semestr 4/ask/lista4/ask21_lista_4.pdf delete mode 100644 Semestr 4/ask/lista5/ask21_lista_5.pdf delete mode 100644 Semestr 4/ask/lista5/puzzle3.s delete mode 100644 Semestr 4/ask/lista5/puzzle4.s delete mode 100644 Semestr 4/ask/lista5/puzzle5.s delete mode 100644 Semestr 4/ask/lista5/zad1.asm delete mode 100644 Semestr 4/ask/lista5/zad1.c delete mode 100644 Semestr 4/ask/lista5/zad1.s delete mode 100644 Semestr 4/ask/lista5/zad2.asm delete mode 100644 Semestr 4/ask/lista5/zad2.c delete mode 100644 Semestr 4/ask/lista5/zad3.c delete mode 100644 Semestr 4/ask/lista5/zad4.c delete mode 100644 Semestr 4/ask/lista5/zad5.c delete mode 100644 Semestr 4/ask/lista6/puzzle.c delete mode 100644 Semestr 4/ask/lista6/puzzle.s delete mode 100644 Semestr 4/ask/lista6/puzzle7.s delete mode 100644 Semestr 4/ask/lista6/puzzle8.c delete mode 100644 Semestr 4/ask/lista6/puzzle8.s delete mode 100644 Semestr 4/ask/lista6/test.c delete mode 100644 Semestr 4/ask/lista6/zad7.c delete mode 100644 Semestr 4/ask/lista7/eval.s delete mode 100644 Semestr 4/ask/lista7/wrap.s delete mode 100644 Semestr 4/ask/lista7/zad5.c delete mode 100644 Semestr 4/ask/lista7/zad5.s delete mode 100644 Semestr 4/ask/lista7/zad7.cpp delete mode 100644 Semestr 4/ask/lista7/zad7.ll delete mode 100755 Semestr 4/ask/lista8/._lista_8 delete mode 100644 Semestr 4/ask/lista8/ask21_lista_8.tgz delete mode 100644 Semestr 4/ask/lista8/bar.c delete mode 100644 Semestr 4/ask/lista8/even.c delete mode 100644 Semestr 4/ask/lista8/foo.c delete mode 100644 Semestr 4/ask/lista8/lazy.c delete mode 100644 Semestr 4/ask/lista8/main.lds delete mode 100644 Semestr 4/ask/lista8/merge-1.map delete mode 100644 Semestr 4/ask/lista8/merge-2.map delete mode 100644 Semestr 4/ask/lista8/mismatch-a.c delete mode 100644 Semestr 4/ask/lista8/mismatch-b.c delete mode 100644 Semestr 4/ask/lista8/odd.c delete mode 100644 Semestr 4/ask/lista8/relo3.c delete mode 100644 Semestr 4/ask/lista8/start.c delete mode 100644 Semestr 4/ask/lista8/str-a.c delete mode 100644 Semestr 4/ask/lista8/str-b.c delete mode 100644 Semestr 4/ask/lista8/swap.c delete mode 100644 Semestr 4/ask/lista9/gadget.s delete mode 100644 Semestr 4/ask/lista9/lazy.c delete mode 100644 Semestr 4/ask/lista9/lista_9.tgz delete mode 100644 Semestr 4/ask/lista9/relo3.c delete mode 100644 Semestr 4/ask/lista9/ropex.c delete mode 100644 Semestr 4/ask/lista9/ropex.in (1).txt delete mode 100644 Semestr 4/ask/lista9/ropex.in.txt delete mode 100644 Semestr 4/ask/lista9/ropex.map delete mode 100644 Semestr 4/ask/lista9/test.c delete mode 100644 Semestr 4/ask/lista9/test.s delete mode 100644 "Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/hackersdelight.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" delete mode 100644 Semestr 4/ask/zadanie1/rozw.c delete mode 100644 Semestr 4/pstwo/kol1/FranciszekMalinkaKolokwium1.pdf delete mode 100644 Semestr 4/pstwo/lista1/L1Z4.pdf delete mode 100644 Semestr 4/pstwo/lista1/RP1R_01.pdf delete mode 100644 Semestr 4/pstwo/lista10/L10.pdf delete mode 100644 Semestr 4/pstwo/lista10/RP1R_10.pdf delete mode 100644 Semestr 4/pstwo/lista2/L2Z11.pdf delete mode 100644 Semestr 4/pstwo/lista2/RP1R_02.pdf delete mode 100644 Semestr 4/pstwo/lista3/L3Z4.pdf delete mode 100644 Semestr 4/pstwo/lista3/RP1R_03.pdf delete mode 100644 Semestr 4/pstwo/lista4/L4Z15.pdf delete mode 100644 Semestr 4/pstwo/lista4/RP1R_04.pdf delete mode 100644 Semestr 4/pstwo/lista5/L5Z12.pdf delete mode 100644 Semestr 4/pstwo/lista5/RP1R_05.pdf delete mode 100644 Semestr 4/pstwo/lista6/L6Z13.pdf delete mode 100644 Semestr 4/pstwo/lista6/RP1R_06.pdf delete mode 100644 Semestr 4/pstwo/lista7/RP1R_07.pdf delete mode 100644 Semestr 4/pstwo/lista8/RP1R_08.pdf delete mode 100644 Semestr 4/pstwo/lista9/RP1R_09.pdf delete mode 100644 Semestr 4/pstwo/lista9/l9z3.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 10.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 11.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 12.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 2.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 3.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 4.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 5.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 7.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 8.pdf delete mode 100644 Semestr 4/pstwo/wyklady/Wyklad 9.pdf delete mode 100644 "Semestr 4/pstwo/wyklady/Wyk\305\202ad 1.pdf" delete mode 100644 "Semestr 4/pstwo/wyklady/Wyk\305\202ad 6.pdf" delete mode 100644 Semestr 4/pstwo/wyklady/w1.svg delete mode 100644 Semestr 4/rr1r/kol1/kol1.xopp delete mode 100644 Semestr 4/rr1r/kol1/zad1.pdf delete mode 100644 Semestr 4/rr1r/kol1/zad2.pdf delete mode 100644 Semestr 4/rr1r/kol1/zad3.pdf delete mode 100644 Semestr 4/rr1r/lista1/L1Z3.pdf delete mode 100644 Semestr 4/rr1r/lista1/RR1R-01.pdf delete mode 100644 Semestr 4/rr1r/lista2/L2Z4.pdf delete mode 100644 Semestr 4/rr1r/lista2/L2Z9.pdf delete mode 100644 Semestr 4/rr1r/lista2/RR1R-02.pdf delete mode 100644 Semestr 4/rr1r/lista3/RR1R-03.pdf delete mode 100644 Semestr 4/rr1r/lista4/RR1R-04.pdf delete mode 100644 Semestr 4/rr1r/lista5/RR1R-05.pdf delete mode 100644 Semestr 4/rr1r/lista6/RR1R-06.pdf delete mode 100644 Semestr 4/rr1r/lista7/RR1R-07.pdf delete mode 100644 Semestr 4/rr1r/lista8/L8.pdf delete mode 100644 Semestr 4/rr1r/lista8/RR1R-08.pdf delete mode 100644 Semestr 4/rr1r/lista9/RR1R-09.pdf delete mode 100644 Semestr 4/sieci/cwiczenia1/c1.pdf delete mode 100644 Semestr 4/sieci/cwiczenia1/cw1.pdf delete mode 100644 Semestr 4/sieci/cwiczenia1/out.pdf delete mode 100644 Semestr 4/sieci/cwiczenia1/rozw.pdf delete mode 100644 Semestr 4/sieci/cwiczenia2/c2.pdf delete mode 100644 Semestr 4/sieci/pracownia1/makefile delete mode 100644 Semestr 4/sieci/pracownia1/p1.pdf delete mode 100644 Semestr 4/sieci/pracownia1/traceroute.c delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka.tar.xz delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/config.h delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.c delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.h delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/makefile delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.c delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.h delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/router.c delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/test.c delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/utils.c delete mode 100644 Semestr 4/sieci/pracownia2/franciszek_malinka/utils.h delete mode 100644 Semestr 4/sieci/pracownia2/p2.pdf delete mode 100644 Semestr 4/sieci/pracownia2/router/config.h delete mode 100644 Semestr 4/sieci/pracownia2/router/dist_vector.c delete mode 100644 Semestr 4/sieci/pracownia2/router/dist_vector.h delete mode 100644 Semestr 4/sieci/pracownia2/router/linked_list.c delete mode 100644 Semestr 4/sieci/pracownia2/router/linked_list.h delete mode 100644 Semestr 4/sieci/pracownia2/router/makefile delete mode 100644 Semestr 4/sieci/pracownia2/router/network_addr.c delete mode 100644 Semestr 4/sieci/pracownia2/router/network_addr.h delete mode 100644 Semestr 4/sieci/pracownia2/router/router.c delete mode 100644 Semestr 4/sieci/pracownia2/router/test.c delete mode 100644 Semestr 4/sieci/pracownia2/router/utils.c delete mode 100644 Semestr 4/sieci/pracownia2/router/utils.h delete mode 100755 Semestr 4/sieci/pracownia2/udp_client.c delete mode 100755 Semestr 4/sieci/pracownia2/udp_server.c delete mode 100644 Semestr 4/sieci/pracownia3/config.h delete mode 100644 Semestr 4/sieci/pracownia3/p3.pdf delete mode 100644 Semestr 4/sieci/pracownia3/transport.c delete mode 100644 Semestr 4/sieci/pracownia3/utils.c delete mode 100644 Semestr 4/sieci/pracownia3/utils.h delete mode 100644 Semestr 4/sieci/pracownia3/window.c delete mode 100644 Semestr 4/sieci/pracownia3/window.h delete mode 100644 Semestr 4/sieci/pracownia4/p4.pdf delete mode 100644 Semestr 4/sieci/warsztaty1/w1.pdf delete mode 100644 Semestr 4/sieci/warsztaty2/w2.pdf delete mode 100644 Semestr 4/sieci/warsztaty3/w3.pdf delete mode 100644 Semestr 4/sieci/warsztaty4/w4.pdf delete mode 100644 Semestr 4/sieci/warsztaty5/w5.pdf delete mode 100644 Semestr 4/sieci/warsztaty6/w6.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec1.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec2.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec3.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec4.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec5.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec6.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec7.pdf delete mode 100644 Semestr 4/sieci/wyklady/lec8.pdf (limited to 'Semestr 4') diff --git a/Semestr 4/aisd/lista0/L0Z8.md b/Semestr 4/aisd/lista0/L0Z8.md deleted file mode 100644 index d9c8604..0000000 --- a/Semestr 4/aisd/lista0/L0Z8.md +++ /dev/null @@ -1,51 +0,0 @@ -# AiSD, L0Z8 - -Dane: $n$, $m$. -Wynik: (Współczynnik przy $x^2$) $\mod m$ wielomianu $\underbrace{(\ldots((x-2)^2 -2)^2\ldots - 2)^2}_{n\text{ razy}}$. - -**Obserwacja 1:** Wszystkie obliczenia możemy wykonywać $\mod m$. Nie zwiększa to złożoności obliczeniowej, a ogranicza wartości które musimy utrzymywać. - -**Obserwacja 2:** Obliczając współczynniki wielomianu nie musimy obliczać współczynników przy większej potędze $x$ niż $2$. - -Niech $w_k(x)$ = $\underbrace{(\ldots((x-2)^2 -2)^2\ldots - 2)^2}_{k\text{ razy}}$, ale bez wyrazów gdzie $x$ występuje w potędze większej niż $2$. Dla jasności przyjmujemy $w_0(x) = x$. - -Mamy w takim razie $w_k(x) = a_k + b_kx + c_kx^2$. Ponadto: -\begin{align} - w_{k+1}(x) &= (a_k + b_kx + c_kx^2 - 2)^2 \\ - &= \underbrace{(a_k^2 - 4a_k + 4)}_{a_{k+1}} + \underbrace{(2a_kb_k - 4b_k)}_{b_{k+1}}x + \underbrace{(2a_kc_k + b_k^2 - 4c_k)}_{c_{k+1}}x^2 -\end{align} - -Dostajemy zatem układ rekurencyjny: -\begin{cases} -a_0=c_0=0 \\ -b_0=1 \\ -a_{k+1} = a_k^2 - 4a_k + 4 = (a_k - 2)^2 \\ -b_{k+1} = 2a_kb_k - 4b_k \\ -c_{k+1} = 2a_kc_k + b_k^2 - 4c_k \\ -\end{cases} - -**Obserwacja 3:** $a_k = 4$ dla $k \ge 1$. Faktycznie, policzmy $a_1 = (a_0 - 2)^2 = 4$. Ale $a_2 = (4 - 2)^2 = 4$. Zatem ciąg ten jest stale równy $4$ od $k = 1$. - -**Obserwacja 4:** $b_k = -(4^k)$ dla $k \ge 1$. Korzystając z zależności rekurencyjnej dla $k \ge 1$ mamy $b_{k+1} = 2b_k(a_k - 2) = 4b_k$, ale $b_1 = -4$, zatem $b_k = -(4^k)$. - -Korzystając z obserwacji 3. i 4. upraszczamy zależność rekurencyjną na $c_{k+1}$ dla $k\ge 1$: -\begin{align} -c_{k+1} = 8c_k + 4^{2k} - 4c_k = 4c_k + 4^{2k} -\end{align} - -Stąd już dostajemy łatwą zależność (dla $k\ge 1$): - -$$ -\left[\begin{array}{cc} -4 & 1\\ -0 & 16 -\end{array}\right] -\left[\begin{array}{cc} -c_k\\ -4^{2k} -\end{array}\right] = -\left[\begin{array}{cc} -c_{k+1}\\ -4^{2(k+1)} -\end{array}\right] -$$ \ No newline at end of file diff --git a/Semestr 4/aisd/lista0/Rozw L0.pdf b/Semestr 4/aisd/lista0/Rozw L0.pdf deleted file mode 100644 index d39c13b..0000000 Binary files a/Semestr 4/aisd/lista0/Rozw L0.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista0/lista0.pdf b/Semestr 4/aisd/lista0/lista0.pdf deleted file mode 100644 index 31b9daa..0000000 Binary files a/Semestr 4/aisd/lista0/lista0.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista1/Lista 1.pdf b/Semestr 4/aisd/lista1/Lista 1.pdf deleted file mode 100644 index 7e2f5ae..0000000 Binary files a/Semestr 4/aisd/lista1/Lista 1.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista1/lista1.pdf b/Semestr 4/aisd/lista1/lista1.pdf deleted file mode 100644 index a7dc065..0000000 Binary files a/Semestr 4/aisd/lista1/lista1.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista2/Lista 2.pdf b/Semestr 4/aisd/lista2/Lista 2.pdf deleted file mode 100644 index ccf83b7..0000000 Binary files a/Semestr 4/aisd/lista2/Lista 2.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista2/lista2.pdf b/Semestr 4/aisd/lista2/lista2.pdf deleted file mode 100644 index 2d8937f..0000000 Binary files a/Semestr 4/aisd/lista2/lista2.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista3/huff.pdf b/Semestr 4/aisd/lista3/huff.pdf deleted file mode 100644 index bf2cfec..0000000 Binary files a/Semestr 4/aisd/lista3/huff.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista3/huffman.pdf b/Semestr 4/aisd/lista3/huffman.pdf deleted file mode 100644 index 1881a27..0000000 Binary files a/Semestr 4/aisd/lista3/huffman.pdf and /dev/null differ diff --git a/Semestr 4/aisd/lista3/lista3.pdf b/Semestr 4/aisd/lista3/lista3.pdf deleted file mode 100644 index 74514b8..0000000 Binary files a/Semestr 4/aisd/lista3/lista3.pdf and /dev/null differ diff --git a/Semestr 4/aisd/pracownia1/pracownia1.pdf b/Semestr 4/aisd/pracownia1/pracownia1.pdf deleted file mode 100644 index 2b99ba4..0000000 Binary files a/Semestr 4/aisd/pracownia1/pracownia1.pdf and /dev/null differ diff --git a/Semestr 4/aisd/pracownia1/rozw.cpp b/Semestr 4/aisd/pracownia1/rozw.cpp deleted file mode 100644 index acbd711..0000000 --- a/Semestr 4/aisd/pracownia1/rozw.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -using namespace std; -typedef long long ll; - -vector>> v; -const int MAX_LEN = 85; -int bits[100]; - -int main() { - ios_base::sync_with_stdio(false); - cin.tie(); - int n; - cin >> n; - for (int i = 0; i < n; i++) { - int d, nd; - cin >> d >> nd; - int k = 0; - while (d % 2 == 0) { - d /= 2; - k++; - } - v.push_back({d, {k, nd}}); - } - sort(v.begin(), v.end()); - int result = 0; - - for (int i = 0; i < n; ) { - int h = i; - int d = v[i].first; - while (h < n && v[h].first == d) { - h++; - } - for (int k = 0; k < MAX_LEN; k++) - bits[k] = 0; - for (int j = i; j < h; ++j) { - ll x = (ll)(1LL << v[j].second.first) * (ll)v[j].second.second; - int k = 0; - while (x > 0) { - if (x % 2 == 1) { - bits[k]++; - } - x /= 2; - k++; - } - } - - for (int k = 0; k < MAX_LEN; k++) { - if (bits[k] > 1) { - bits[k + 1] += bits[k]/2; - } - if (bits[k] % 2 == 1) { - result++; - } - } - i = h; - } - - cout << result << "\n"; -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia1/rozw2.cpp b/Semestr 4/aisd/pracownia1/rozw2.cpp deleted file mode 100644 index 35fd37e..0000000 --- a/Semestr 4/aisd/pracownia1/rozw2.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -using namespace std; -typedef unsigned long long ll; - -vector> v; - -int main() { - int n; - scanf("%d", &n); - for (int i = 0; i < n; i++) { - int d, nd, k = 0; - scanf("%d %d", &d, &nd); - while (d % 2 == 0) { - k++; - d /= 2; - } - v.push_back({d, (ll)(1LL< sum: - print("N musi być mniejsze równe od sum.") - exit() - -t = [1 for i in range(n)] - -for i in range(sum - n): - idx = randint(0, n - 1) - t[idx] += 1 - -print(n) -for i in t: - print(i, end=' ') -print() diff --git a/Semestr 4/aisd/pracownia2/gen_test.sh b/Semestr 4/aisd/pracownia2/gen_test.sh deleted file mode 100755 index d5bff05..0000000 --- a/Semestr 4/aisd/pracownia2/gen_test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -mkdir -p tests -cp gen.py tests/ -cd tests - -python3 gen.py 1 5 20 > t1.in -python3 gen.py 2 10 100 > t2.in -python3 gen.py 3 20 200 > t3.in -python3 gen.py 4 40 600 > t4.in -python3 gen.py 5 80 5000 > t5.in -python3 gen.py 6 160 10000 > t6.in -python3 gen.py 7 320 10000 > t7.in -python3 gen.py 8 640 20000 > t8.in -python3 gen.py 9 1280 20000 > t9.in -python3 gen.py 10 2000 2000 > t10.in -python3 gen.py 11 2000 20000 > t11.in -python3 gen.py 12 2000 200000 > t12.in -python3 gen.py 13 2000 1000000 > t13.in -python3 gen.py 14 2000 1000000 > t14.in -python3 gen.py 15 2000 1000000 > t15.in - - -rm gen.py diff --git a/Semestr 4/aisd/pracownia2/rozw.cpp b/Semestr 4/aisd/pracownia2/rozw.cpp deleted file mode 100644 index dd0d700..0000000 --- a/Semestr 4/aisd/pracownia2/rozw.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -using namespace std; - -const int MAX_SUM = 1e6; -const int N = 2e3 + 10; - -unordered_map sums; -vector> v; - -int main() { - int n; - scanf("%d", &n); - sums[0] = 0; - for (int i = 0; i < n; i++) { - int h; - scanf("%d", &h); - v.clear(); - for (auto kv: sums) { - v.push_back(kv); - } - - for (auto kv: v) { - int dif = kv.first, best = kv.second; - cout << dif << " " << best << "\n"; - int aux = 0; - if (dif >= 0) { - aux = h; - } else if (dif + h > 0) { - aux = dif + h; - } - - cout << ">aux: " << aux << " "; - sums[dif + h] = max(sums[dif + h], best + aux); - aux = 0; - if (dif <= 0) { - aux = h; - } else if (dif - h < 0) { - aux = h - dif; - } - cout << aux << "\n"; - sums[dif - h] = max(sums[dif - h], best + aux); - } - cout << "---\n"; - } - for (auto kv: sums) { - printf("%d %d\n", kv.first, kv.second); - } - - if (sums[0] != 0) { - printf("TAK\n%d\n", sums[0]); - } else { - int mini = 1e9; - sums.erase(0); - for (auto kv: sums) { - mini = min(mini, abs(kv.first)); - } - printf("NIE\n%d\n", mini); - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia2/rozw2.cpp b/Semestr 4/aisd/pracownia2/rozw2.cpp deleted file mode 100644 index fa0b2d6..0000000 --- a/Semestr 4/aisd/pracownia2/rozw2.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -using namespace std; - -const int MAX_SUM = 5e5; - -int t[2][MAX_SUM * 2 + 10]; -int H[2003]; -uint8_t eligible[2][MAX_SUM * 2 + 10]; // 0 - not used, 1 - only st, 2 - only nd, 3 - both - -int main() { - int n, sum = 0, which = 0; - scanf("%d", &n); - for (int i = 0; i < n; i++) - scanf("%d", &H[i]); - sort(H, H + n); - - for (int i = 0; i < n; i++) { - // cout << i << "\n"; - int h = H[i], *prev = t[which], *cur = t[which ^ 1]; - uint8_t *pe = eligible[which], *ce = eligible[which ^ 1]; - - for (int dif = -sum; dif <= sum; ++dif) { - int aux = 0; - // cout << (int)pe[dif + MAX_SUM] << "\n"; - - if (abs(dif) > MAX_SUM || (pe[dif + MAX_SUM] == 0 && dif != 0)) continue; - - if (dif + h <= MAX_SUM) { - if (dif >= 0) { - aux = h; - } else if (dif + h > 0) { - aux = dif + h; - } - int idx = dif + h + MAX_SUM; - - cur[idx] = max({cur[idx], prev[idx], prev[idx - h] + aux}); - ce[idx] |= pe[dif + MAX_SUM] | 1; - // cout << "> " << idx - MAX_SUM << " " << cur[idx] << " " << (int)eligible[idx] << "\n"; - } - - if (dif - h >= -MAX_SUM) { - aux = 0; - if (dif <= 0) { - aux = h; - } else if (dif - h < 0) { - aux = h - dif; - } - int idx = dif - h + MAX_SUM; - cur[idx] = max({cur[idx], prev[idx], prev[idx + h] + aux}); - ce[idx] |= pe[dif + MAX_SUM] | 2; - // cout << ">> " << idx - MAX_SUM << " " << cur[idx] << " " << (int)eligible[idx] << "\n"; - } - } - sum += h; - which ^= 1; - // for (int dif = -sum; dif <= sum; ++dif) { - // cout << dif << " " << " " << (int)ce[dif + MAX_SUM] << " " << cur[dif + MAX_SUM] << "\n"; - // } - // printf("-----\n"); - } - if (eligible[which][MAX_SUM] == 3) { - printf("TAK\n%d\n", t[which][MAX_SUM]); - } else { - int mini = 1e9; - for (int i = -MAX_SUM; i <= MAX_SUM; i++) { - if (eligible[which][i + MAX_SUM] == 3) - mini = min(mini, abs(i)); - } - printf("NIE\n%d\n", mini); - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia2/rozw3.cpp b/Semestr 4/aisd/pracownia2/rozw3.cpp deleted file mode 100644 index 8e3dd2a..0000000 --- a/Semestr 4/aisd/pracownia2/rozw3.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -using namespace std; - -#define RIGHT 0 -#define LEFT 1 - -const int MAXN = 2e3 + 10; -const int M = 5e5 + 10; - -int n, H[MAXN], dp[2][M*2]; -bool vis[2][M*2], both[2][M*2]; - -int get_val() - -int main() { - ios_base::sync_with_stdio(false); - cin.tie(); - cin >> n; - for (int i = 0; i < n; i++) { - cin >> H[i]; - } - - int sum = 0, K = 0; - vis[K^1][0] = true; - for (int i = 0; i < n; i++) { - int h = H[i]; - for (int cur = -sum; cur <= sum; ++cur) { - vis[K][cur + M] |= vis[K^1][cur + M]; - both[K][cur + M] |= both[K^1][cur + M]; - dp[K][cur + M] = max({dp[K][cur + M], dp[K^1][cur + M]}); - if (vis[K][cur + M]) { - int val = dp[K][cur + M]; - int left = cur + M - h; - int right = cur + M + h; - - if (cur - h >= 0) { - both[K][right] = true; - } - vis[K][right] = true; - dp[K][right] = max({dp[K][right], dp[K^1][right], dp[K^1][right] + h}); - - if (cur + h <= 0) { - both[K][left]= true; - } - vis[K][left] = true; - dp[K][left] = max({dp[K][left], dp[K^1][left], dp[K^1][left] + h}); - } - } - K^=1; - for (int cur = -sum; cur <= sum; ++cur) { - dp[K][cur + M] = 0; - vis[K][cur + M] = 0; - both[K][cur + M] = 0; - } - sum += h; - } - K^=1; - if (both[K][M]) { - cout << "TAK\n"; - cout << dp[K][M] << "\n"; - } else { - cout << "NIE\n"; - int best = -sum; - for (int cur = -sum ; cur <= sum; ++cur) { - if (both[cur + M] && abs(cur) < abs(best)) { - best = cur; - } - } - cout << abs(best) << "\n"; - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia2/rozw4.cpp b/Semestr 4/aisd/pracownia2/rozw4.cpp deleted file mode 100644 index 73ff79a..0000000 --- a/Semestr 4/aisd/pracownia2/rozw4.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -using namespace std; - -const int MAX_SUM = 1e6, MAXN = 2004; -int n; -int dp[2][MAX_SUM + 10], H[MAXN]; - -int main() { - scanf("%d", &n); - for (int i = 0; i < n; ++i) { - scanf("%d", &H[i]); - } - - sort(H, H + n); - - int sum = 0, K = 0; - for (int i = 0; i < n; ++i) { - int h = H[i]; - for (int i = 0; i <= min(sum, MAX_SUM); i++) - dp[K^1][i] = dp[K][i]; - - for (int i = 0; i <= min(sum, MAX_SUM); i++) { - if (i != 0 && dp[K][i] == 0) continue; - - int left = abs(i - h), aux = i-h >= 0 ? 0 : h-i; - if (left <= MAX_SUM) { - dp[K^1][left] = max(dp[K^1][left], dp[K][i] + aux); - } - int right = i + h; - if (right <= MAX_SUM) { - dp[K^1][right] = max(dp[K^1][right], dp[K][i] + h); - } - } - - K ^= 1; - sum += h; - } - if (dp[K][0] != 0) { - printf("TAK\n%d\n", dp[K][0]); - } - else { - int res = 0; - for (int i = 1; i <= MAX_SUM; i++) { - if (dp[K][i] != i && dp[K][i]) { - res = i; - break; - } - } - printf("NIE\n%d\n", res); - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia2/show_problem.pdf b/Semestr 4/aisd/pracownia2/show_problem.pdf deleted file mode 100644 index 4ab0312..0000000 Binary files a/Semestr 4/aisd/pracownia2/show_problem.pdf and /dev/null differ diff --git a/Semestr 4/aisd/pracownia3/check.cpp b/Semestr 4/aisd/pracownia3/check.cpp deleted file mode 100644 index c9c74d7..0000000 --- a/Semestr 4/aisd/pracownia3/check.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include -using namespace std; - -int n, p, m; -int banned[103][3][3]; -int plane[5][10]; - -bool check(int k, int i, int pp) { - for (int kk = k; kk < k + 3; kk++) { - for (int ii = i; ii < i + 3; ii++) { - if (plane[kk][ii] != banned[pp][kk-k][ii-i]) - return false; - } - } - return true; -} - -void debug(int pp) { - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - cout << ((banned[pp][i][j] == 0) ? '.' : 'x'); - } - cout << "\n"; - } -} - -void debug() { - for (int k = 0; k < 5; ++k) { - for (int i = 0; i < n; ++i) { - cout << (plane[k][i] ? 'x' : '.'); - } - cout << "\n"; - } - cout << "\n"; -} - -int ile[1030]; - -int main() { - cin >> n >> p >> m; - for (int i = 0; i < p; i++) { - for (int k = 0; k < 3; k++) { - string s; - cin >> s; - for (int j = 0; j < 3; ++j) { - banned[i][k][j] = (s[j] == 'x'); - } - } - } - int res = 0; - for (int mask = 0; mask < (1<<(5 * n)); mask++) { - for (int k = 0; k < 5; ++k) { - for (int i = 0; i < n; i++) { - plane[k][i] = ((mask & (1 << (k * n + i))) > 0); - } - } - bool dziala = true; - for (int k = 0; k < 3; ++k) { - for (int i = 0; i < n-2; ++i) { - for (int j = 0; j < p; ++j) { - if (check(k, i, j)) { - dziala = false; - break; - } - } - if (!dziala) break; - } - if (!dziala) break; - } - if (dziala) { - res++; - if (res == m) { - res = 0; - } - int mm = 0; - for (int i = 0; i < 5; ++i) { - mm += plane[i][n-2] * (1<<(i*2)); - mm += plane[i][n-1] * (1<<(i*2 + 1)); - } - ile[mm]++; - } - } - for (int i = 0; i < 1024; ++i) { - cout << i << ": " << ile[i] << "\n"; - } - cout << res % m << "\n"; -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia3/gen.py b/Semestr 4/aisd/pracownia3/gen.py deleted file mode 100644 index b572647..0000000 --- a/Semestr 4/aisd/pracownia3/gen.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -mask = int(sys.argv[1]) -print(3, 1, 1000000) - -def f(m): - t = [[0]*3]*3 - for i in range(3): - for j in range(3): - t[i][j] = (m >> (i*3 + j)) & 1 - print('x' if t[i][j] else '.', end='') - print() - -f(mask) \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia3/ocen.sh b/Semestr 4/aisd/pracownia3/ocen.sh deleted file mode 100755 index 593aa67..0000000 --- a/Semestr 4/aisd/pracownia3/ocen.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -make rozw -make check -for i in {0..1023} -do - python3 gen.py $i > t.in - ./rozw < t.in > wa.out - ./check < t.in > t.out - if diff -w wa.out t.out - then - echo $i - echo ok - else - echo nieok - break - fi -done \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia3/rozw.cpp b/Semestr 4/aisd/pracownia3/rozw.cpp deleted file mode 100644 index 7f1a307..0000000 --- a/Semestr 4/aisd/pracownia3/rozw.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include -using namespace std; - -const int MAXP = 105; -const int MAXN = 5005; - -int n, p, m; -unordered_set banned; -vector> propagate; -int dp[2][1024 + 10]; - -inline int char_to_bit(char c) { - return c == '.' ? 0 : 1; -} - -void input() { - scanf("%d%d%d", &n, &p, &m); - for (int i = 0; i < p; i++) { - char s[5]; - int value = 0, d = 1; - for (int k = 0; k < 3; k++) { - scanf("%s", s); - value += (char_to_bit(s[0]) + char_to_bit(s[1]) * 2 + char_to_bit(s[2]) * 4) * d; - d *= 8; - } - banned.insert(value); - } -} - -pair> get_pieces_values(int db, int sb) { - int tab[5][3]; - for (int i = 0; i < 5; i++) { - tab[i][0] = (db >> (i*2)) & 1; - tab[i][1] = (db >> (i*2 + 1)) & 1; - tab[i][2] = (sb >> i) & 1; - } - int res[3]; - for (int k = 0; k < 3; ++k) { - int value = 0, d = 1; - for (int i = k; i < k + 3; ++i) { - value += (tab[i][0] + tab[i][1] * 2 + tab[i][2] * 4) * d; - d *= 8; - } - res[k] = value; - } - return {res[0], {res[1], res[2]}}; -} - -int combine(int db, int sb) { - int res = (db >> 1) & 0x155; - for (int i = 0; i < 5; i++) { - res |= ((sb >> i) & 1) << (2*i + 1); - } - return res; -} - -void preproces() { - const int db = (1<<10); // double bar - const int sb = (1<<5); // single bar - - for (int db_mask = 0; db_mask < db; ++db_mask) { - for (int sb_mask = 0; sb_mask < sb; ++sb_mask) { - auto pieces = get_pieces_values(db_mask, sb_mask); - if (banned.count(pieces.first) || banned.count(pieces.second.first) || banned.count(pieces.second.second)) - continue; - int db2_mask = combine(db_mask, sb_mask); - propagate.push_back({db_mask, db2_mask}); - } - } -} - -int compute_dp() { - int K = 1; - for (int i = 0; i < 1024; i++) { - dp[0][i] = 1; - } - for (int i = 2; i < n; i++) { - for (auto pp: propagate) { - int p1 = pp.first, p2 = pp.second; - dp[K][p2] += dp[K^1][p1]; - dp[K][p2] %= m; - } - K ^= 1; - for (int j = 0; j < 1024; ++j) { - dp[K][j] = 0; - } - } - - K ^= 1; - int result = 0; - for (int i = 0; i < 1024; i++) { - result += dp[K][i]; - result %= m; - } - return result; -} - -int main() { - input(); - preproces(); - printf("%d\n", compute_dp()); -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia3/show_problem.pdf b/Semestr 4/aisd/pracownia3/show_problem.pdf deleted file mode 100644 index f426311..0000000 Binary files a/Semestr 4/aisd/pracownia3/show_problem.pdf and /dev/null differ diff --git a/Semestr 4/aisd/pracownia3/wa.outr b/Semestr 4/aisd/pracownia3/wa.outr deleted file mode 100644 index 81a8bb1..0000000 --- a/Semestr 4/aisd/pracownia3/wa.outr +++ /dev/null @@ -1,1025 +0,0 @@ -0: 613 -1: 745 -2: 729 -3: 745 -4: 881 -5: 881 -6: 881 -7: 881 -8: 849 -9: 865 -10: 849 -11: 865 -12: 881 -13: 881 -14: 881 -15: 881 -16: 1025 -17: 1025 -18: 1025 -19: 1025 -20: 1025 -21: 1025 -22: 1025 -23: 1025 -24: 1025 -25: 1025 -26: 1025 -27: 1025 -28: 1025 -29: 1025 -30: 1025 -31: 1025 -32: 977 -33: 993 -34: 977 -35: 993 -36: 1009 -37: 1009 -38: 1009 -39: 1009 -40: 977 -41: 993 -42: 977 -43: 993 -44: 1009 -45: 1009 -46: 1009 -47: 1009 -48: 1025 -49: 1025 -50: 1025 -51: 1025 -52: 1025 -53: 1025 -54: 1025 -55: 1025 -56: 1025 -57: 1025 -58: 1025 -59: 1025 -60: 1025 -61: 1025 -62: 1025 -63: 1025 -64: 881 -65: 1025 -66: 1009 -67: 1025 -68: 1025 -69: 1025 -70: 1025 -71: 1025 -72: 1009 -73: 1025 -74: 1009 -75: 1025 -76: 1025 -77: 1025 -78: 1025 -79: 1025 -80: 1025 -81: 1025 -82: 1025 -83: 1025 -84: 1025 -85: 1025 -86: 1025 -87: 1025 -88: 1025 -89: 1025 -90: 1025 -91: 1025 -92: 1025 -93: 1025 -94: 1025 -95: 1025 -96: 1009 -97: 1025 -98: 1009 -99: 1025 -100: 1025 -101: 1025 -102: 1025 -103: 1025 -104: 1009 -105: 1025 -106: 1009 -107: 1025 -108: 1025 -109: 1025 -110: 1025 -111: 1025 -112: 1025 -113: 1025 -114: 1025 -115: 1025 -116: 1025 -117: 1025 -118: 1025 -119: 1025 -120: 1025 -121: 1025 -122: 1025 -123: 1025 -124: 1025 -125: 1025 -126: 1025 -127: 1025 -128: 861 -129: 993 -130: 977 -131: 993 -132: 1009 -133: 1009 -134: 1009 -135: 1009 -136: 977 -137: 993 -138: 977 -139: 993 -140: 1009 -141: 1009 -142: 1009 -143: 1009 -144: 1025 -145: 1025 -146: 1025 -147: 1025 -148: 1025 -149: 1025 -150: 1025 -151: 1025 -152: 1025 -153: 1025 -154: 1025 -155: 1025 -156: 1025 -157: 1025 -158: 1025 -159: 1025 -160: 977 -161: 993 -162: 977 -163: 993 -164: 1009 -165: 1009 -166: 1009 -167: 1009 -168: 977 -169: 993 -170: 977 -171: 993 -172: 1009 -173: 1009 -174: 1009 -175: 1009 -176: 1025 -177: 1025 -178: 1025 -179: 1025 -180: 1025 -181: 1025 -182: 1025 -183: 1025 -184: 1025 -185: 1025 -186: 1025 -187: 1025 -188: 1025 -189: 1025 -190: 1025 -191: 1025 -192: 881 -193: 1025 -194: 1009 -195: 1025 -196: 1025 -197: 1025 -198: 1025 -199: 1025 -200: 1009 -201: 1025 -202: 1009 -203: 1025 -204: 1025 -205: 1025 -206: 1025 -207: 1025 -208: 1025 -209: 1025 -210: 1025 -211: 1025 -212: 1025 -213: 1025 -214: 1025 -215: 1025 -216: 1025 -217: 1025 -218: 1025 -219: 1025 -220: 1025 -221: 1025 -222: 1025 -223: 1025 -224: 1009 -225: 1025 -226: 1009 -227: 1025 -228: 1025 -229: 1025 -230: 1025 -231: 1025 -232: 1009 -233: 1025 -234: 1009 -235: 1025 -236: 1025 -237: 1025 -238: 1025 -239: 1025 -240: 1025 -241: 1025 -242: 1025 -243: 1025 -244: 1025 -245: 1025 -246: 1025 -247: 1025 -248: 1025 -249: 1025 -250: 1025 -251: 1025 -252: 1025 -253: 1025 -254: 1025 -255: 1025 -256: 745 -257: 881 -258: 865 -259: 881 -260: 1025 -261: 1025 -262: 1025 -263: 1025 -264: 993 -265: 1009 -266: 993 -267: 1009 -268: 1025 -269: 1025 -270: 1025 -271: 1025 -272: 1025 -273: 1025 -274: 1025 -275: 1025 -276: 1025 -277: 1025 -278: 1025 -279: 1025 -280: 1025 -281: 1025 -282: 1025 -283: 1025 -284: 1025 -285: 1025 -286: 1025 -287: 1025 -288: 993 -289: 1009 -290: 993 -291: 1009 -292: 1025 -293: 1025 -294: 1025 -295: 1025 -296: 993 -297: 1009 -298: 993 -299: 1009 -300: 1025 -301: 1025 -302: 1025 -303: 1025 -304: 1025 -305: 1025 -306: 1025 -307: 1025 -308: 1025 -309: 1025 -310: 1025 -311: 1025 -312: 1025 -313: 1025 -314: 1025 -315: 1025 -316: 1025 -317: 1025 -318: 1025 -319: 1025 -320: 881 -321: 1025 -322: 1009 -323: 1025 -324: 1025 -325: 1025 -326: 1025 -327: 1025 -328: 1009 -329: 1025 -330: 1009 -331: 1025 -332: 1025 -333: 1025 -334: 1025 -335: 1025 -336: 1025 -337: 1025 -338: 1025 -339: 1025 -340: 1025 -341: 1025 -342: 1025 -343: 1025 -344: 1025 -345: 1025 -346: 1025 -347: 1025 -348: 1025 -349: 1025 -350: 1025 -351: 1025 -352: 1009 -353: 1025 -354: 1009 -355: 1025 -356: 1025 -357: 1025 -358: 1025 -359: 1025 -360: 1009 -361: 1025 -362: 1009 -363: 1025 -364: 1025 -365: 1025 -366: 1025 -367: 1025 -368: 1025 -369: 1025 -370: 1025 -371: 1025 -372: 1025 -373: 1025 -374: 1025 -375: 1025 -376: 1025 -377: 1025 -378: 1025 -379: 1025 -380: 1025 -381: 1025 -382: 1025 -383: 1025 -384: 873 -385: 1009 -386: 993 -387: 1009 -388: 1025 -389: 1025 -390: 1025 -391: 1025 -392: 993 -393: 1009 -394: 993 -395: 1009 -396: 1025 -397: 1025 -398: 1025 -399: 1025 -400: 1025 -401: 1025 -402: 1025 -403: 1025 -404: 1025 -405: 1025 -406: 1025 -407: 1025 -408: 1025 -409: 1025 -410: 1025 -411: 1025 -412: 1025 -413: 1025 -414: 1025 -415: 1025 -416: 993 -417: 1009 -418: 993 -419: 1009 -420: 1025 -421: 1025 -422: 1025 -423: 1025 -424: 993 -425: 1009 -426: 993 -427: 1009 -428: 1025 -429: 1025 -430: 1025 -431: 1025 -432: 1025 -433: 1025 -434: 1025 -435: 1025 -436: 1025 -437: 1025 -438: 1025 -439: 1025 -440: 1025 -441: 1025 -442: 1025 -443: 1025 -444: 1025 -445: 1025 -446: 1025 -447: 1025 -448: 881 -449: 1025 -450: 1009 -451: 1025 -452: 1025 -453: 1025 -454: 1025 -455: 1025 -456: 1009 -457: 1025 -458: 1009 -459: 1025 -460: 1025 -461: 1025 -462: 1025 -463: 1025 -464: 1025 -465: 1025 -466: 1025 -467: 1025 -468: 1025 -469: 1025 -470: 1025 -471: 1025 -472: 1025 -473: 1025 -474: 1025 -475: 1025 -476: 1025 -477: 1025 -478: 1025 -479: 1025 -480: 1009 -481: 1025 -482: 1009 -483: 1025 -484: 1025 -485: 1025 -486: 1025 -487: 1025 -488: 1009 -489: 1025 -490: 1009 -491: 1025 -492: 1025 -493: 1025 -494: 1025 -495: 1025 -496: 1025 -497: 1025 -498: 1025 -499: 1025 -500: 1025 -501: 1025 -502: 1025 -503: 1025 -504: 1025 -505: 1025 -506: 1025 -507: 1025 -508: 1025 -509: 1025 -510: 1025 -511: 1025 -512: 741 -513: 873 -514: 857 -515: 873 -516: 1009 -517: 1009 -518: 1009 -519: 1009 -520: 977 -521: 993 -522: 977 -523: 993 -524: 1009 -525: 1009 -526: 1009 -527: 1009 -528: 1025 -529: 1025 -530: 1025 -531: 1025 -532: 1025 -533: 1025 -534: 1025 -535: 1025 -536: 1025 -537: 1025 -538: 1025 -539: 1025 -540: 1025 -541: 1025 -542: 1025 -543: 1025 -544: 977 -545: 993 -546: 977 -547: 993 -548: 1009 -549: 1009 -550: 1009 -551: 1009 -552: 977 -553: 993 -554: 977 -555: 993 -556: 1009 -557: 1009 -558: 1009 -559: 1009 -560: 1025 -561: 1025 -562: 1025 -563: 1025 -564: 1025 -565: 1025 -566: 1025 -567: 1025 -568: 1025 -569: 1025 -570: 1025 -571: 1025 -572: 1025 -573: 1025 -574: 1025 -575: 1025 -576: 881 -577: 1025 -578: 1009 -579: 1025 -580: 1025 -581: 1025 -582: 1025 -583: 1025 -584: 1009 -585: 1025 -586: 1009 -587: 1025 -588: 1025 -589: 1025 -590: 1025 -591: 1025 -592: 1025 -593: 1025 -594: 1025 -595: 1025 -596: 1025 -597: 1025 -598: 1025 -599: 1025 -600: 1025 -601: 1025 -602: 1025 -603: 1025 -604: 1025 -605: 1025 -606: 1025 -607: 1025 -608: 1009 -609: 1025 -610: 1009 -611: 1025 -612: 1025 -613: 1025 -614: 1025 -615: 1025 -616: 1009 -617: 1025 -618: 1009 -619: 1025 -620: 1025 -621: 1025 -622: 1025 -623: 1025 -624: 1025 -625: 1025 -626: 1025 -627: 1025 -628: 1025 -629: 1025 -630: 1025 -631: 1025 -632: 1025 -633: 1025 -634: 1025 -635: 1025 -636: 1025 -637: 1025 -638: 1025 -639: 1025 -640: 861 -641: 993 -642: 977 -643: 993 -644: 1009 -645: 1009 -646: 1009 -647: 1009 -648: 977 -649: 993 -650: 977 -651: 993 -652: 1009 -653: 1009 -654: 1009 -655: 1009 -656: 1025 -657: 1025 -658: 1025 -659: 1025 -660: 1025 -661: 1025 -662: 1025 -663: 1025 -664: 1025 -665: 1025 -666: 1025 -667: 1025 -668: 1025 -669: 1025 -670: 1025 -671: 1025 -672: 977 -673: 993 -674: 977 -675: 993 -676: 1009 -677: 1009 -678: 1009 -679: 1009 -680: 977 -681: 993 -682: 977 -683: 993 -684: 1009 -685: 1009 -686: 1009 -687: 1009 -688: 1025 -689: 1025 -690: 1025 -691: 1025 -692: 1025 -693: 1025 -694: 1025 -695: 1025 -696: 1025 -697: 1025 -698: 1025 -699: 1025 -700: 1025 -701: 1025 -702: 1025 -703: 1025 -704: 881 -705: 1025 -706: 1009 -707: 1025 -708: 1025 -709: 1025 -710: 1025 -711: 1025 -712: 1009 -713: 1025 -714: 1009 -715: 1025 -716: 1025 -717: 1025 -718: 1025 -719: 1025 -720: 1025 -721: 1025 -722: 1025 -723: 1025 -724: 1025 -725: 1025 -726: 1025 -727: 1025 -728: 1025 -729: 1025 -730: 1025 -731: 1025 -732: 1025 -733: 1025 -734: 1025 -735: 1025 -736: 1009 -737: 1025 -738: 1009 -739: 1025 -740: 1025 -741: 1025 -742: 1025 -743: 1025 -744: 1009 -745: 1025 -746: 1009 -747: 1025 -748: 1025 -749: 1025 -750: 1025 -751: 1025 -752: 1025 -753: 1025 -754: 1025 -755: 1025 -756: 1025 -757: 1025 -758: 1025 -759: 1025 -760: 1025 -761: 1025 -762: 1025 -763: 1025 -764: 1025 -765: 1025 -766: 1025 -767: 1025 -768: 745 -769: 881 -770: 865 -771: 881 -772: 1025 -773: 1025 -774: 1025 -775: 1025 -776: 993 -777: 1009 -778: 993 -779: 1009 -780: 1025 -781: 1025 -782: 1025 -783: 1025 -784: 1025 -785: 1025 -786: 1025 -787: 1025 -788: 1025 -789: 1025 -790: 1025 -791: 1025 -792: 1025 -793: 1025 -794: 1025 -795: 1025 -796: 1025 -797: 1025 -798: 1025 -799: 1025 -800: 993 -801: 1009 -802: 993 -803: 1009 -804: 1025 -805: 1025 -806: 1025 -807: 1025 -808: 993 -809: 1009 -810: 993 -811: 1009 -812: 1025 -813: 1025 -814: 1025 -815: 1025 -816: 1025 -817: 1025 -818: 1025 -819: 1025 -820: 1025 -821: 1025 -822: 1025 -823: 1025 -824: 1025 -825: 1025 -826: 1025 -827: 1025 -828: 1025 -829: 1025 -830: 1025 -831: 1025 -832: 881 -833: 1025 -834: 1009 -835: 1025 -836: 1025 -837: 1025 -838: 1025 -839: 1025 -840: 1009 -841: 1025 -842: 1009 -843: 1025 -844: 1025 -845: 1025 -846: 1025 -847: 1025 -848: 1025 -849: 1025 -850: 1025 -851: 1025 -852: 1025 -853: 1025 -854: 1025 -855: 1025 -856: 1025 -857: 1025 -858: 1025 -859: 1025 -860: 1025 -861: 1025 -862: 1025 -863: 1025 -864: 1009 -865: 1025 -866: 1009 -867: 1025 -868: 1025 -869: 1025 -870: 1025 -871: 1025 -872: 1009 -873: 1025 -874: 1009 -875: 1025 -876: 1025 -877: 1025 -878: 1025 -879: 1025 -880: 1025 -881: 1025 -882: 1025 -883: 1025 -884: 1025 -885: 1025 -886: 1025 -887: 1025 -888: 1025 -889: 1025 -890: 1025 -891: 1025 -892: 1025 -893: 1025 -894: 1025 -895: 1025 -896: 873 -897: 1009 -898: 993 -899: 1009 -900: 1025 -901: 1025 -902: 1025 -903: 1025 -904: 993 -905: 1009 -906: 993 -907: 1009 -908: 1025 -909: 1025 -910: 1025 -911: 1025 -912: 1025 -913: 1025 -914: 1025 -915: 1025 -916: 1025 -917: 1025 -918: 1025 -919: 1025 -920: 1025 -921: 1025 -922: 1025 -923: 1025 -924: 1025 -925: 1025 -926: 1025 -927: 1025 -928: 993 -929: 1009 -930: 993 -931: 1009 -932: 1025 -933: 1025 -934: 1025 -935: 1025 -936: 993 -937: 1009 -938: 993 -939: 1009 -940: 1025 -941: 1025 -942: 1025 -943: 1025 -944: 1025 -945: 1025 -946: 1025 -947: 1025 -948: 1025 -949: 1025 -950: 1025 -951: 1025 -952: 1025 -953: 1025 -954: 1025 -955: 1025 -956: 1025 -957: 1025 -958: 1025 -959: 1025 -960: 881 -961: 1025 -962: 1009 -963: 1025 -964: 1025 -965: 1025 -966: 1025 -967: 1025 -968: 1009 -969: 1025 -970: 1009 -971: 1025 -972: 1025 -973: 1025 -974: 1025 -975: 1025 -976: 1025 -977: 1025 -978: 1025 -979: 1025 -980: 1025 -981: 1025 -982: 1025 -983: 1025 -984: 1025 -985: 1025 -986: 1025 -987: 1025 -988: 1025 -989: 1025 -990: 1025 -991: 1025 -992: 1009 -993: 1025 -994: 1009 -995: 1025 -996: 1025 -997: 1025 -998: 1025 -999: 1025 -1000: 1009 -1001: 1025 -1002: 1009 -1003: 1025 -1004: 1025 -1005: 1025 -1006: 1025 -1007: 1025 -1008: 1025 -1009: 1025 -1010: 1025 -1011: 1025 -1012: 1025 -1013: 1025 -1014: 1025 -1015: 1025 -1016: 1025 -1017: 1025 -1018: 1025 -1019: 1025 -1020: 1025 -1021: 1025 -1022: 1025 -1023: 1025 -37456 diff --git a/Semestr 4/aisd/pracownia4/brut.cpp b/Semestr 4/aisd/pracownia4/brut.cpp deleted file mode 100644 index 32f4ebb..0000000 --- a/Semestr 4/aisd/pracownia4/brut.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include -using namespace std; -typedef long long ll; - -struct insert_list { - vector v; - - insert_list() { - } - - void insert(int p, int val) { - assert(p <= v.size()); - assert(p >= 0); - vector temp; - for (int i = 0; i < p; i++) { - temp.push_back(v[i]); - } - temp.push_back(val); - for (int i = p; i < v.size(); i++) { - temp.push_back(v[i]); - } - v = temp; - } - - void erase(int p) { - assert(p <= v.size()); - assert(p >= 1); - vector temp; - for (int i = 0; i < p-1; i++) { - temp.push_back(v[i]); - } - for (int i = p; i < v.size(); i++) { - temp.push_back(v[i]); - } - v = temp; - } - - ll sum(int l, int r) { - ll ans = 0; - for (int i = l-1; i < r; i++) { - ans += v[i]; - } - return ans; - } -}; - -insert_list v; - -int main() { - ios_base::sync_with_stdio(false); - cin.tie(); - int n; - cin >> n; - for (int i = 0; i < n; i++) { - char c; - cin >> c; - if (c == 'D') { - int a; - cin >> a; - v.erase(a); - } - else { - int a, b; - cin >> a >> b; - if (c == 'I') v.insert(a, b); - else cout << v.sum(a,b) << "\n"; - } - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia4/gen.py b/Semestr 4/aisd/pracownia4/gen.py deleted file mode 100644 index 733a60e..0000000 --- a/Semestr 4/aisd/pracownia4/gen.py +++ /dev/null @@ -1,24 +0,0 @@ -from random import randint, seed, choice -import sys - - -seed(sys.argv[1]) -n = int(sys.argv[2]) -l = 0 -print(n) - - -for i in range(n): - c = choice('ISD') - if l == 0: - c = 'I' - - if c == 'D': - print(c, randint(1, l)) - l -= 1 - elif c == 'I': - print(c, randint(0, l), randint(-10, 10)) - l += 1 - else: - a = randint(1, l) - print(c, a, randint(a, l)) \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia4/rozw.cpp b/Semestr 4/aisd/pracownia4/rozw.cpp deleted file mode 100644 index 9c314e2..0000000 --- a/Semestr 4/aisd/pracownia4/rozw.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include -using namespace std; -typedef long long ll; - -const int K = 20; -const int M = (1<= 0; d--) { - int maks = (1< queries; -map q_to_pos; -kox_set secik; -kox_set pstree; - - -int main() { - int n, inserts = 0; - scanf("%d", &n); - for (int i = 0; i < n; ++i) { - char c; - scanf(" %c", &c); - query q; - q.type = c; - if (c == 'D') { - int a; - scanf("%d", &a); - pstree.add(a); - q.info.del = a; - } - else { - int a, b; - scanf("%d%d", &a, &b); - q.type = c; - if (c == 'I') { - q.info.insert = {a, b}; - inserts++; - } else { - q.info.sum = {a, b}; - } - } - queries.push_back(q); - } - - secik.fill(1); - for (int i = n-1; i >= 0; i--) { - query q = queries[i]; - if (q.type == 'D') { - pstree.del(q.info.del); - } - if (q.type == 'I') { - int offset = pstree.sum(0, q.info.insert.p); - int kth = secik.kth_elem(q.info.insert.p + offset + 1); - secik.del(kth); - q_to_pos[i] = kth; - cout << q.info.insert.p << " " << offset << "\n"; - cout << i << ": " << q_to_pos[i] << "\n"; - } - } - secik.fill(0); - pstree.fill(0); - - for (int i = 0; i < n; i++) { - query q = queries[i]; - if (q.type == 'I') { - secik.add(q_to_pos[i]); - pstree.update(q_to_pos[i], q.info.insert.x); - // cout << "Inserting " << q.info.insert.x << " to " << q_to_pos[i] << "\n"; - } - if (q.type == 'D') { - int pos = secik.kth_elem(q.info.del); - // cout << "kth: " << q.info.del << " " << pos << "\n"; - secik.del(pos); - pstree.update(pos, -pstree.tree[pos + M]); - } - if (q.type == 'S') { - int from = secik.kth_elem(q.info.sum.from); - int to = secik.kth_elem(q.info.sum.to); - printf("%lld\n", pstree.sum(from, to)); - } - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia4/rozw2.cpp b/Semestr 4/aisd/pracownia4/rozw2.cpp deleted file mode 100644 index 17562a9..0000000 --- a/Semestr 4/aisd/pracownia4/rozw2.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include -using namespace std; - -struct treap { - typedef long long T; - treap *left = nullptr; - treap *right = nullptr; - int rank, items = 1; - T value; - T sum; - bool rev = false; - - treap(T val = T()) : rank(rand()), value(val), sum(val) {} - - inline void update() { - if (rev) { - swap(left, right); - if (left) left->rev = !left->rev; - if (right) right->rev = !right->rev; - rev = false; - } - } -}; - -inline int items(treap *t) { return t ? t->items : 0; } -inline int sum(treap *t) { return t ? t->sum : 0; } -inline void recalc(treap *t) { - t->items = items(t->left) + items(t->right) + 1; - t->sum = sum(t->left) + sum(t->right) + t->value; -} - -pair split(treap *t, int k) { - if (!t) return {nullptr, nullptr}; - t->update(); - if (items(t->left) < k) { - auto p = split(t->right, k - items(t->left) - 1); - t->right = p.first; - recalc(t); - return {t, p.second}; - } - else { - auto p = split(t->left, k); - t->right = p.first; - recalc(t); - return {p.first, t}; - } -} - -treap* merge(treap *a, treap *b) { - if (!a) return b; - if (!b) return a; - a->update(); - b->update(); - if (a->rank > b->rank) { - a->right = merge(a->right, b); - recalc(a); - return a; - } - else { - b->left = merge(a, b->left); - recalc(b); - return b; - } -} - -treap::T select(treap *t, int k) { - if (!t) return treap::T(); - t->update(); - int i = items(t->left); - if (i == k) return t->value; - else if (i > k) return select(t->left, k); - else return select(t->right, k - i - 1); -} - -treap *insert (treap *t, treap::T val, int k) { - auto p = split(t, k); - return merge(merge(p.first, new treap(val)), p.second); -} - -treap *erase(treap *t, int k) { - auto p1 = split(t, k); - auto p2 = split(p1.second, 1); - return merge(p1.first, p2.second); -} - -treap::T sum(treap *t, int l, int r) { - auto p1 = split(t, r); - auto p2 = split(p1.first, l); - return sum(p2.second); -} - -void write(treap *t) { - if (!t) return; - t->update(); - write(t->left); - cout << t->value << " "; - write(t->right); -} -void destroy(treap *t) { - if (!t) return; - destroy(t->left); - destroy(t->right); - delete t; -} - -treap *t = 0; - -int main() { - int n; - scanf("%d", &n); - for (int i = 0; i < n; i++) { - char c; - scanf(" %c", &c); - if (c == 'I') { - int p, x; - scanf("%d%d", &p, &x); - t = insert(t, x, p); - } - if (c == 'D') { - int p; - scanf("%d", &p); - t = erase(t, p - 1); - } - if (c == 'S') { - int l, r; - scanf("%d%d", &l, &r); - printf("ans: %lld\n", sum(t, l, r)); - } - cout << "Treap:\n"; - write(t); - cout << "\n"; - } - - destroy(t); -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia4/rozw3.cpp b/Semestr 4/aisd/pracownia4/rozw3.cpp deleted file mode 100644 index ec107ef..0000000 --- a/Semestr 4/aisd/pracownia4/rozw3.cpp +++ /dev/null @@ -1,149 +0,0 @@ - -#include -using namespace std; - -struct treap -{ - typedef long long T; - treap *left = nullptr, *right = nullptr; - - int rank, items = 1; - bool rev = false; - T value, sum; - - treap(T val = T()) : value(val), sum(val), rank(rand()) { } - - inline void update() - { - if(rev) - { - swap(left, right); - if(left) left->rev = !left->rev; - if(right) right->rev = !right->rev; - rev = false; - } - } -}; - -inline int items(treap *t) { return t ? t->items : 0; } -inline treap::T sum(treap *t) { return t ? t->sum : 0; } -inline void recalc(treap *t) { - t->items = items(t->left) + items(t->right) + 1; - t->sum = sum(t->left) + sum(t->right) + t->value; -} - -pair split(treap *t, int k) //dzieli na prefiks dlugosci k i reszte -{ - if(!t) return make_pair(nullptr, nullptr); - //t = new treap(*t); //odkomentowac zeby zrobic strukture trwala - t->update(); - if(items(t->left) < k) - { - auto p = split(t->right, k - items(t->left) - 1); - t->right = p.first; - recalc(t); - return make_pair(t, p.second); - } - else - { - auto p = split(t->left, k); - t->left = p.second; - recalc(t); - return make_pair(p.first, t); - } -} - -treap* merge(treap *a, treap *b) -{ - if(!a) return b; - if(!b) return a; - a->update(); - b->update(); - if(a->rank > b->rank) { - a->right = merge(a->right, b); - recalc(a); - return a; - } - else { - b->left = merge(a, b->left); - recalc(b); - return b; - } -} - -treap::T select(treap *t, int k) //zwraca k-ty element -{ - if(!t) return treap::T(); - t->update(); - int i = items(t->left); - if(i == k) return t->value; - if(i > k) return select(t->left, k); - return select(t->right, k - i - 1); -} - -treap* insert(treap *t, treap::T val, int k) //wstaw val na pozycje k (liczac od 0) -{ - auto p = split(t, k); - return merge(merge(p.first, new treap(val)), p.second); -} -void write(treap *t) -{ - if(!t) return; - t->update(); - write(t->left); - cout << "(" << t->value << ", " << t->sum << ") "; - write(t->right); -} - -treap* erase(treap *t, int k) -{ - auto p1 = split(t, k); - auto p2 = split(p1.second, 1); - return merge(p1.first, p2.second); -} - -treap* reverse(treap *t, int a, int b) //odwroc przedzial rev = !p2.second->rev; - return merge(merge(p2.first, p2.second), p1.second); -} - -treap::T sum(treap* t, int l, int r) { - auto p1 = split(t, r); - auto p2 = split(p1.first, l); - treap::T ret = sum(p2.second); - merge(merge(p2.first, p2.second), p1.second); - return ret; -} - -treap *root = 0; - -int main() { - int n; - scanf("%d", &n); - for (int i = 0; i < n; i++) { - char c; - scanf(" %c", &c); - if (c == 'I') { - int p, x; - scanf("%d%d", &p, &x); - root = insert(root, x, p); - } - if (c == 'D') { - int p; - scanf("%d", &p); - root = erase(root, p - 1); - } - if (c == 'S') { - int l, r; - scanf("%d%d", &l, &r); - printf("%lld\n", sum(root, l - 1, r)); - } - // cout << "Treap:\n"; - // write(root); - // cout << "\n"; - } - -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia4/show_problem.pdf b/Semestr 4/aisd/pracownia4/show_problem.pdf deleted file mode 100644 index 8a1c155..0000000 Binary files a/Semestr 4/aisd/pracownia4/show_problem.pdf and /dev/null differ diff --git a/Semestr 4/aisd/pracownia4/test.sh b/Semestr 4/aisd/pracownia4/test.sh deleted file mode 100755 index dc725ad..0000000 --- a/Semestr 4/aisd/pracownia4/test.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -make brut -make rozw3 - - -for i in {1..10000} -do - echo $i - python3 gen.py $i $1 > test.in - ./rozw3 < test.in > wa.out - ./brut < test.in > test.out - - if diff -w test.out wa.out - then - echo ok - else - echo nieok - break - fi -done diff --git a/Semestr 4/aisd/pracownia5/gen.py b/Semestr 4/aisd/pracownia5/gen.py deleted file mode 100644 index 283cd04..0000000 --- a/Semestr 4/aisd/pracownia5/gen.py +++ /dev/null @@ -1,40 +0,0 @@ -import random -import sys - -random.seed(sys.argv[1]) - -n = int(sys.argv[2]) -maxcoord = 1000 - - -print(n) -for i in range(n): - ty = random.randint(0, 3) - a, b = 0, 0 - y1, y2 = 0, 0 - if ty == 0: - a = random.randint(0, maxcoord) - b = random.randint(a+1, maxcoord + 1) - y1 = random.randint(0, maxcoord) - y2 = y1 - if ty == 1: - y1 = random.randint(0, maxcoord) - y2 = random.randint(a+1, maxcoord + 1) - a = random.randint(0, maxcoord) - b = a - if ty == 2: - a = random.randint(0, maxcoord) - b = random.randint(0, maxcoord) - x = random.randint(1, maxcoord) - y1 = b - b = a + x - y2 = y1 + x - if ty == 3: - a = random.randint(0, maxcoord) - b = random.randint(0, maxcoord) - x = random.randint(1, maxcoord) - y1 = b - b = a + x - y2 = y1 - x - - print(a, y1, b, y2) diff --git a/Semestr 4/aisd/pracownia5/wzo.cpp b/Semestr 4/aisd/pracownia5/wzo.cpp deleted file mode 100644 index 14056c8..0000000 --- a/Semestr 4/aisd/pracownia5/wzo.cpp +++ /dev/null @@ -1,286 +0,0 @@ -#include -using namespace std; - -#define VER_T 1 -#define HOR_T 0 - -#define BEG 0 -#define END 1 - -struct event { - int x, y, z; - bool t; - event(int _x=0, bool _t=false, int _y=0, int _z=0) : x(_x), y(_y), z(_z), t(_t) {} - - bool operator < (const event &e) const { - if (x == e.x) { - if (t == e.t) return make_pair(y, z) < make_pair(e.y, e.z); - if (t == HOR_T) return z == BEG; - if (e.t == HOR_T) return e.z == END; - return t < e.t; - // if (t == HOR_T && z == BEG) return true; - // else if (t == HOR_T) return false; - // else if (e.t == HOR_T && e.z == BEG) return false; - // else if (e.t == HOR_T) return true; - // return (make_pair(y,z) < make_pair(e.y, e.z)); - } - return x < e.x; - // return make_pair(x, make_pair(t, make_pair(y, z))) < make_pair(e.x, make_pair(e.t, make_pair(e.y, e.z))); - } - -}; - -struct pnt { - int x, y; - - pnt(int _x=0, int _y=0) : x(_x), y(_y) {} - - void transpoze(int a11, int a12, int a21, int a22) { - int temp = x*a11 + y*a12; - y = x*a21 + y*a22; - x = temp; - } - bool operator == (const pnt &p) { - return (x==p.x && y == p.y); - } - -}; - -struct seg { - pnt st, nd; - - seg(pnt p1=pnt(), pnt p2=pnt()) : st(p1), nd(p2) {} - - void transpoze(int a11, int a12, int a21, int a22) { - st.transpoze(a11, a12, a21, a22); - nd.transpoze(a11, a12, a21, a22); - } -}; - -inline int sig(int x) { - if (x < 0) return -1; - if (x == 0) return 0; - if (x > 0) return 1; -} - -void swap(pnt &x, pnt &y) { - swap(x.x, y.x); - swap(x.y, y.y); -} - -vector events; -map points; - -void get_cross_pnts(vector &result, vector &hor, vector &ver) { - events.resize(0); - points.clear(); - // cout << "h:\n"; - for (auto &s: hor) { - if (s.st.x > s.nd.x) swap(s.st, s.nd); - // cout << s.st.x << " " << s.st.y << ", " << s.nd.x << " " << s.nd.y << "\n"; - events.push_back(event(s.st.x, HOR_T, s.st.y, BEG)); - events.push_back(event(s.nd.x, HOR_T, s.st.y, END)); - } - // cout << "v:\n"; - for (auto &s: ver) { - if (s.st.y > s.nd.y) swap(s.st, s.nd); - // cout << s.st.x << " " << s.st.y << ", " << s.nd.x << " " << s.nd.y << "\n"; - - events.push_back(event(s.st.x, VER_T, s.st.y, s.nd.y)); - } - - sort(events.begin(), events.end()); - for (auto e: events) { - // cout << e.x << " " << (e.t == HOR_T ? "hor " : "ver ") << e.y << " " << (e.t == HOR_T ? (e.z == BEG ? "beg" : "end") : to_string(e.z)) << "\n"; - if (e.t == HOR_T) { - if (e.z == BEG) points[e.y]++; - else { - if (--points[e.y] == 0) points.erase(e.y); - } - } - else { - auto it = points.lower_bound(e.y); - while (it != points.end() && it->first <= e.z) { - result.push_back(pnt(e.x, it->first)); - it++; - } - } - } - // cout << "done\n"; -} - -vector temp; -vector hor, ver, cross_left, cross_right; - -void read() { - int n; - // cin >> n; - scanf("%d", &n); - for (int i = 0; i < n; i++) { - int x1, y1, x2, y2; - // cin >> x1 >> y1 >> x2 >> y2; - scanf("%d%d%d%d", &x1, &y1, &x2, &y2); - seg s = seg(pnt(x1, y1), pnt(x2, y2)); - if (y1 == y2) - hor.push_back(s); - else if (x1 == x2) - ver.push_back(s); - else if (sig(x1 - x2) == sig(y1 - y2)) - cross_right.push_back(s); - else - cross_left.push_back(s); - } -} - -void hor_ver(vector &result) { - // cout << "hor_ver\n"; - - temp.clear(); - get_cross_pnts(temp, hor, ver); - for (auto p: temp) result.push_back(p); -} - -void hor_c_r(vector &result) { - // cout << "hor_cr\n"; - temp.clear(); - for (auto &p: hor) p.transpoze(1, -1, 0, 1); - for (auto &p: cross_right) p.transpoze(1, -1, 0, 1); - get_cross_pnts(temp, hor, cross_right); - for (auto &p: hor) p.transpoze(1, 1, 0, 1); - for (auto &p: cross_right) p.transpoze(1, 1, 0, 1); - - for (auto &p: temp) { - p.transpoze(1, 1, 0, 1); - result.push_back(p); - } -} - -void hor_c_l(vector &result) { - // cout << "hor_cl\n"; - temp.clear(); - for (auto &p: hor) p.transpoze(1, 1, 0, 1); - for (auto &p: cross_left) p.transpoze(1, 1, 0, 1); - - get_cross_pnts(temp, hor, cross_left); - - for (auto &p: hor) p.transpoze(1, -1, 0, 1); - for (auto &p: cross_left) p.transpoze(1, -1, 0, 1); - - for (auto &p: temp) { - p.transpoze(1, -1, 0, 1); - result.push_back(p); - } -} - -void ver_c_r(vector &result) { - // cout << "ver_cr\n"; - - temp.clear(); - for (auto &p: ver) { - p.transpoze(1, 0, -1, 1); - } - for (auto &p: cross_right) { - p.transpoze(1, 0, -1, 1); - } - - get_cross_pnts(temp, cross_right, ver); - - for (auto &p: ver) { - p.transpoze(1, 0, 1, 1); - } - for (auto &p: cross_right) { - p.transpoze(1, 0, 1, 1); - } - - for (auto &p: temp) { - p.transpoze(1, 0, 1, 1); - result.push_back(p); - } -} - -void ver_c_l(vector &result) { - // cout << "ver_cl\n"; - - temp.clear(); - for (auto &p: ver) { - p.transpoze(-1, 0, 1, 1); - } - for (auto &p: cross_left) { - p.transpoze(-1, 0, 1, 1); - } - - get_cross_pnts(temp, cross_left, ver); - for (auto &p: ver) { - p.transpoze(-1, 0, 1, 1); - } - for (auto &p: cross_left) { - p.transpoze(-1, 0, 1, 1); - } - - for (auto &p: temp) { - p.transpoze(-1, 0, 1, 1); - result.push_back(p); - } -} - -void c_l_c_r(vector &result) { - temp.clear(); - // cout << "cl_cr\n"; - for (auto &p: cross_right) { - // cout << p.st.x << " " << p.st.y << ", " << p.nd.x << " " << p.nd.y << "\n"; - p.transpoze(1, 1, -1, 1); - } - // cout << "---\n"; - for (auto &p: cross_left) { - // cout << p.st.x << " " << p.st.y << ", " << p.nd.x << " " << p.nd.y << "\n"; - p.transpoze(1, 1, -1, 1); - } - - get_cross_pnts(temp, cross_right, cross_left); - - for (auto &p: ver) { - p.transpoze(1, -1, 1, 1); - } - for (auto &p: cross_left) { - p.transpoze(1, -1, 1, 1); - } - - for (auto &p: temp) { - p.transpoze(1, -1, 1, 1); - result.push_back(p); - } -} - -void solve() { - // cout << hor.size() << " " << ver.size() << " " << cross_left.size() << " " << cross_right.size() << "\n"; - vector result; - hor_ver(result); - hor_c_r(result); - hor_c_l(result); - ver_c_r(result); - ver_c_l(result); - for (auto &p: result) { - p.x *= 2; - p.y *= 2; - } - c_l_c_r(result); - - sort(result.begin(), result.end(), [&](const pnt &p1, const pnt &p2) { - if (p1.x == p2.x) return p1.y < p2.y; - return p1.x < p2.x; - }); - result.erase(unique(result.begin(), result.end()), result.end()); - for (auto p : result) { - printf("%d.%s ", p.x/2, (p.x % 2 == 1 ? "5" : "0")); - printf("%d.%s\n", p.y/2, (p.y % 2 == 1 ? "5" : "0")); - // cout << p.x/2 << "." << (p.x % 2 == 1 ? "5" : "0") << " "; - // cout << p.y/2 << "." << (p.y % 2 == 1 ? "5" : "0") << "\n"; - } -} - -int main() { - // ios_base::sync_with_stdio(false); - // cin.tie(); - read(); - solve(); -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia5/wzo2.cpp b/Semestr 4/aisd/pracownia5/wzo2.cpp deleted file mode 100644 index b4e9ac3..0000000 --- a/Semestr 4/aisd/pracownia5/wzo2.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include -using namespace std; - -/* -[0 -1] -[1 0] -*/ - -struct pnt { - int x, y; - pnt (int _x=0, int _y=0) : x(_x), y(_y) {} - void transpose(int a11, int a12, int a21, int a22) { - int temp = x*a11 + y*a12; - y = x*a21 + y*a22; - x = temp; - } - bool operator<(const pnt &p) const { - if (p.x == x) return y < p.y; - return x < p.x; - } - bool operator==(const pnt &p) const { - return (x == p.x && y == p.y); - } -}; - -struct seg { - pnt st, nd; - seg(pnt p1=pnt(), pnt p2=pnt()) : st(p1), nd(p2) {} - void transpose(int a11, int a12, int a21, int a22) { - st.transpose(a11, a12, a21, a22); - nd.transpose(a11, a12, a21, a22); - } -}; - -#define HOR_T 0 -#define VER_T 1 -#define CL_T 2 -#define CR_T 3 -#define BEG 0 -#define END 1 - -struct event { - int x; - int t; - int i1, i2; - - event(int _x, int _t, int _i1, int _i2) : x(_x), t(_t), i1(_i1), i2(_i2) {} - - bool operator < (const event &e) const { - if (x == e.x) { - if (t == e.t) return make_pair(i1, i2) < make_pair(e.i1, e.i2); - if (t == HOR_T) return (e.i2 == END); - if (e.t == HOR_T) return (i2 == BEG); - return t < e.t; - } - return x < e.x; - } -}; - -inline void swap(pnt &p1, pnt &p2) { - swap(p1.x, p2.x); - swap(p1.y, p2.y); -} - -vector segments; -vector result; -vector temp_res; -vector events; -map hor; -map cl; -map cr; - -void read() { - int n; - scanf("%d", &n); - segments.resize(n); - for (int i = 0; i < n; i++) { - cin >> segments[i].st.x >> segments[i].st.y >> segments[i].nd.x >> segments[i].nd.y; - } -} - -void rotate(int a11, int a12, int a21, int a22) { - for (auto s: segments) { - s.transpose(a11, a12, a21, a22); - } -} - -void solve_prob() { - temp_res.clear(); - events.clear(); - hor.clear(); cl.clear(); cr.clear(); - - for (auto s: segments) { - if (s.st.x > s.nd.x) swap(s.st, s.nd); - if (s.st.x == s.nd.x) { - if (s.st.y > s.nd.y) swap(s.st, s.nd); - events.push_back(event(s.st.x, VER_T, s.st.y, s.nd.y)); - } - else if (s.st.y == s.nd.y) { - events.push_back(event(s.st.x, HOR_T, s.st.y, BEG)); - events.push_back(event(s.nd.x, HOR_T, s.st.y, END)); - } - else if (s.st.y - s.nd.y < 0) { - events.push_back(event(s.st.x, CR_T, s.st.y, BEG)); - events.push_back(event(s.nd.x, CR_T, s.nd.y, END)); - } - else { - events.push_back(event(s.st.x, CL_T, s.st.y, BEG)); - events.push_back(event(s.nd.x, CL_T, s.nd.y, END)); - } - } - - sort(events.begin(), events.end()); - for (auto e: events) { - if (e.t == VER_T) { - auto it = hor.lower_bound(e.i1); - while (it != hor.end() && it->first <= e.i2) { - temp_res.push_back({e.x, it->first}); - it++; - } - it = cr.lower_bound(e.i1 - e.x); - while (it != cr.end() && it->first <= e.i2 - e.x) { - temp_res.push_back({e.x, it->first + e.x}); - it++; - } - it = cl.lower_bound(e.i1 + e.x); - while (it != cl.end() && it->first <= e.i2 + e.x) { - temp_res.push_back({e.x, it->first - e.x}); - it++; - } - } - if (e.t == CR_T) { - if (e.i2 == BEG) cr[e.i1 - e.x]++; - else if (--cr[e.i1 - e.x] <= 0) cr.erase(e.i1 - e.x); - } - if (e.t == CL_T) { - if (e.i2 == BEG) cl[e.i1 + e.x]++; - else if (--cl[e.i1 + e.x] <= 0) cl.erase(e.i1); - } - if (e.t == HOR_T) { - if (e.i2 == BEG) hor[e.i1]++; - else if (--hor[e.i1] <= 0) hor.erase(e.i1); - } - } -} - -void add_to_res(int a11, int a12, int a21, int a22) { - for (auto p: temp_res) { - p.transpose(a11, a12, a21, a22); - result.push_back(p); - } -} - -void solve() { - solve_prob(); - for (auto &p: temp_res) { - p.x *= 2; p.y *= 2; - } - add_to_res(1, 0, 0, 1); - for (auto &p: temp_res) { - p.x /= 2; p.y /= 2; - } - rotate(1, -1, 1, 1); - solve_prob(); - add_to_res(1, 1, -1, 1); - rotate(1, 1, -1, 1); - for (auto &p: temp_res) { - p.x /= 2; p.y /= 2; - } - - - - sort(result.begin(), result.end()); - result.erase(unique(result.begin(), result.end()), result.end()); - for (auto p : result) { - cout << p.x/2 << "." << (p.x % 2 == 1 ? "5" : "0") << " "; - cout << p.y/2 << "." << (p.y % 2 == 1 ? "5" : "0") << "\n"; - } -} - -int main() { - read(); - solve(); -} \ No newline at end of file diff --git a/Semestr 4/aisd/pracownia6/wzo.cpp b/Semestr 4/aisd/pracownia6/wzo.cpp deleted file mode 100644 index f13f0ec..0000000 --- a/Semestr 4/aisd/pracownia6/wzo.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -using namespace std; - -const int N = 1e6 + 10; -bool vis[N]; -int n, m, ranga[N], par[N]; -pair> G[N]; - -int Find(int v) { - if (par[v] == v) return v; - return par[v] = Find(par[v]); -} - -void Union(int v, int u) { - if (ranga[v] > ranga[u]) { - par[u] = v; - } - else { - if (ranga[v] == ranga[u]) ranga[u]++; - par[v] = u; - } -} - -bool traj(int maks) { - -} - -int main() { - scanf("%d%d", &n, &m); - for (int i = 0; i < m; i++) { - int a, b, w; - scanf("%d%d%d", &a, &b, &w); - G[i] = {-w, {a,b}}; - } - sort(G, G+m); - for (int i = 1; i <= n; i++) { - par[i] = i; - ranga[i] = 0; - } - int mini = 1e9; - for (int i = 0; i < m; i++) { - int a = G[i].second.first; - int b = G[i].second.second; - a = Find(a); b = Find(b); - if (a != b) { - Union(a, b); - mini = min(mini, -G[i].first); - } - } - printf("%d\n", mini); -} \ No newline at end of file diff --git a/Semestr 4/aisd/themis/AISDDEBIUT21.cpp b/Semestr 4/aisd/themis/AISDDEBIUT21.cpp deleted file mode 100644 index 3666d69..0000000 --- a/Semestr 4/aisd/themis/AISDDEBIUT21.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Autor: Franciszek Malinka - * Numer indeksu: 316093 - * Prowadzący: WJA - */ - -#include -using namespace std; - -int main() -{ - ios_base::sync_with_stdio(false); - cin.tie(); - int a, b; - cin >> a >> b; - for (int i = a; i <= b; i++) - { - if (i % 2021 == 0) - { - cout << i << " "; - } - } - cout << "\n"; -} \ No newline at end of file diff --git a/Semestr 4/aisd/themis/AISDPOTEGOWANIE.cpp b/Semestr 4/aisd/themis/AISDPOTEGOWANIE.cpp deleted file mode 100644 index c1b76fe..0000000 --- a/Semestr 4/aisd/themis/AISDPOTEGOWANIE.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -using namespace std; - -int fast_pow(int a, int b, int m) -{ - if (b == 0) - { - return 1; - } - long long p = fast_pow(a, b / 2, m); - p = (p * p) % m; - if (b % 2 == 0) - return (int)p; - return (p * (long long)a) % m; -} - -int main() -{ - ios_base::sync_with_stdio(false); - cin.tie(); - int t; - cin >> t; - while (t--) - { - int a, b, m; - cin >> a >> b >> m; - cout << fast_pow(a, b, m) << "\n"; - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/themis/BELLMAN.cpp b/Semestr 4/aisd/themis/BELLMAN.cpp deleted file mode 100644 index 5a65096..0000000 --- a/Semestr 4/aisd/themis/BELLMAN.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -using namespace std; - -const int N = 503; -int dist[N]; -vector>> edges; -int main() -{ - ios_base::sync_with_stdio(false); - cin.tie(); - int n, m, s; - cin >> n >> m >> s; - for (int i = 0; i <= n; i++) - { - dist[i] = 2e9; - } - dist[s] = 0; - for (int i = 0; i < m; i++) - { - int u, v, w; - cin >> u >> v >> w; - edges.push_back({w, {u, v}}); - // edges.push_back({w, {v, u}}); - } - - for (int i = 0; i < n + 1; i++) - { - for (auto e : edges) - { - int w = e.first; - int u = e.second.first; - int v = e.second.second; - if (dist[v] > dist[u] + w) - { - dist[v] = dist[u] + w; - } - } - } - for (auto e : edges) - { - int w = e.first; - int u = e.second.first; - int v = e.second.second; - if (dist[v] > dist[u] + w) - { - cout << "NIE\n"; - return 0; - } - } - for (int i = 0; i < n; i++) - { - if (i != s && dist[i] < 1e9) - cout << i << " " << dist[i] << "\n"; - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/themis/FIB.cpp b/Semestr 4/aisd/themis/FIB.cpp deleted file mode 100644 index dd38c5c..0000000 --- a/Semestr 4/aisd/themis/FIB.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -using namespace std; -typedef long long ll; - -class matrix -{ -public: - ll a, b, c, d; - static ll m; - - matrix(ll _a = 0, ll _b = 0, ll _c = 0, ll _d = 0) : a(_a), b(_b), c(_c), d(_d) {} - - matrix operator*(const matrix &M) const - { - matrix res; - res.a = (a * M.a + b * M.c) % m; - res.b = (a * M.b + b * M.d) % m; - res.c = (c * M.a + d * M.c) % m; - res.d = (c * M.b + d * M.d) % m; - return res; - } -}; - -ll matrix::m = 1; - -matrix fast_pow(matrix M, int w) -{ - matrix res(1, 0, 0, 1); - while (w) - { - if (w % 2 == 1) - res = res * M; - M = M * M; - w >>= 1; - } - return res; -} - -void solve() -{ - int n, m; - cin >> n >> m; - matrix M(0, 1, 1, 1); - matrix::m = m; - cout << fast_pow(M, n + 1).a << "\n"; -} - -int main() -{ - ios_base::sync_with_stdio(false); - cin.tie(); - int t; - cin >> t; - while (t--) - { - solve(); - } -} \ No newline at end of file diff --git a/Semestr 4/aisd/wyklady/Notatka 1 - Preliminaria.pdf b/Semestr 4/aisd/wyklady/Notatka 1 - Preliminaria.pdf deleted file mode 100644 index dc4ee1c..0000000 Binary files a/Semestr 4/aisd/wyklady/Notatka 1 - Preliminaria.pdf and /dev/null differ diff --git a/Semestr 4/aisd/wyklady/Notatka 2 - Kopiec.pdf b/Semestr 4/aisd/wyklady/Notatka 2 - Kopiec.pdf deleted file mode 100644 index c8e76a7..0000000 Binary files a/Semestr 4/aisd/wyklady/Notatka 2 - Kopiec.pdf and /dev/null differ diff --git "a/Semestr 4/aisd/wyklady/Notatka 3 - Zach\305\202any.pdf" "b/Semestr 4/aisd/wyklady/Notatka 3 - Zach\305\202any.pdf" deleted file mode 100644 index 5403789..0000000 Binary files "a/Semestr 4/aisd/wyklady/Notatka 3 - Zach\305\202any.pdf" and /dev/null differ diff --git a/Semestr 4/aisd/wyklady/Notatka 4 - divide and conquer.pdf b/Semestr 4/aisd/wyklady/Notatka 4 - divide and conquer.pdf deleted file mode 100644 index 205b505..0000000 Binary files a/Semestr 4/aisd/wyklady/Notatka 4 - divide and conquer.pdf and /dev/null differ diff --git a/Semestr 4/aisd/wyklady/Notatka 5 - divide and conquer cd.pdf b/Semestr 4/aisd/wyklady/Notatka 5 - divide and conquer cd.pdf deleted file mode 100644 index 48fc8e4..0000000 Binary files a/Semestr 4/aisd/wyklady/Notatka 5 - divide and conquer cd.pdf and /dev/null differ diff --git a/Semestr 4/aisd/wyklady/Notatka 6 - Programowanie Dynamiczne.pdf b/Semestr 4/aisd/wyklady/Notatka 6 - Programowanie Dynamiczne.pdf deleted file mode 100644 index d8b61ce..0000000 Binary files a/Semestr 4/aisd/wyklady/Notatka 6 - Programowanie Dynamiczne.pdf and /dev/null differ diff --git a/Semestr 4/aisd/wyklady/Notatka 7 - Programowanie Dynamiczne cd.pdf b/Semestr 4/aisd/wyklady/Notatka 7 - Programowanie Dynamiczne cd.pdf deleted file mode 100644 index 7040119..0000000 Binary files a/Semestr 4/aisd/wyklady/Notatka 7 - Programowanie Dynamiczne cd.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista0/Lista 0.pdf b/Semestr 4/ask/lista0/Lista 0.pdf deleted file mode 100644 index bffa5cb..0000000 Binary files a/Semestr 4/ask/lista0/Lista 0.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista0/ask21_lista_0.pdf b/Semestr 4/ask/lista0/ask21_lista_0.pdf deleted file mode 100644 index cc9b182..0000000 Binary files a/Semestr 4/ask/lista0/ask21_lista_0.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista0/rozw.c b/Semestr 4/ask/lista0/rozw.c deleted file mode 100644 index c71940a..0000000 --- a/Semestr 4/ask/lista0/rozw.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - - -int main() { - /* Zad. 3 */ - - uint32_t x, k; - scanf("%d%d", &x, &k); - - x &= ~(1<>= y; // floor(x / 2^y) - x &= (1<> y; // ceil(x/2^y) = floor((x + 2^y - 1)/2^y) - - /* Zad. 5 */ - - scanf("%d", &x); - /* jesli x = 2^k, to x = 1000...0. Wtedy x - 1 = 0111...1, zatem x & (x - 1) == 0 - * gdy x jest potęgą dwójki. Łatwo widać, że jeśli x nie jest potęgą dwójki, - * to wiodący bit będzie ten sam, więc koniunkcja bitowa będzie niezerowa */ - printf("%d", (x & (x - 1))); - - /* Zad. 6 */ - - int rev = ((0xff000000 & x) >> 24u) | // można pominąć tę koniunkcję. - ((0xff0000 & x) >> 8u) | - ((0xff00 & x) << 8u) | - ((0xff & x) << 24u); - - /* Zad. 7 */ - - /* Kod sterujący - kod, który nie niesie informacji o znaku, ale niesie jakąś - * instrukcję sterującą dla urządzenia, np. do terminala. - * ASCII (American Standard Code for Information Interchange) - zestaw znaków, - * który stał się standardem w komunikacji elektronicznej. - * 0, NUL - znak nie niosący żadnej informacji. Może informować np. o końcu danych tekstowych - * 4, EOT (end of thread/end of transmission), ^D - informuje o końcu transmisji danych, - * które mogły zawierać więcej niż jeden tekst. - * 7, BEL (bell), ^G - instruuje urządzenie do wysłania dźwięku. - * 10, LF (line feed), \n - instruuje urządzenie do przejścia do nowej linii, - * ale nie do jej początku. Z tego względu jest często wiązany z CR (carriage return), - * który instruuje urządzenie do powrotu do początku wiersza. W systemach UNIX sam \n - * wystarczy. - * 12, FF (Form feed) - instruuje np. drukarki do przejścia do pierwszego wiersza - * następnej kartkii. - */ - - /* Zad. 8 */ - - /* UTF-8 (8-bit Unicode Transformation Format) - alternatywny zestaw znaków, - * w pełni kompatybilny z ASCII. Wykorzystuje od 1 do 4 bajtów do zakodowania - * pojedyńczego znaku. ASCII ma do dyspozycji jedynie 128 możliwych znaków, co - * zdecydowanie jest mniejsze niż potrzebna liczba znaków do zakodowania. - * Wykorzystanie 4 bajtów pozwala na gwałtowne zwiększenie tej liczby. - * - * Proszę zapłacić 5€! ę - U+0119 (0000 0001 0001 1001), spacja - U+0020, - * ł - U+0142 (0000 0001 0100 0010), € - U+20AC (0010 0000 1010 1100) - * 01010000 01110010 01101111 01110011 01111010 [1100 0100 1001 1001] - * 00100000 - * 01111010 01010001 01110000 [1100 0101 1000 0010] 01010001 01010011 01011001 [1100 0100 1000 0111] - * 00100000 - * 00110101 [1110 0010 1000 0010 1010 1100] 00100001 - */ - - return 0; -} \ No newline at end of file diff --git a/Semestr 4/ask/lista1/ask21_lista_1.pdf b/Semestr 4/ask/lista1/ask21_lista_1.pdf deleted file mode 100644 index 9afcd65..0000000 Binary files a/Semestr 4/ask/lista1/ask21_lista_1.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista1/rozw.c b/Semestr 4/ask/lista1/rozw.c deleted file mode 100644 index 0b4c208..0000000 --- a/Semestr 4/ask/lista1/rozw.c +++ /dev/null @@ -1,217 +0,0 @@ -#include -#include - - -static const int S[] = {1, 2, 4, 8, 16}; // Magic Binary Numbers -static const int B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF}; - -char* utb(uint32_t x) { - static char rep[36]; - int cnt = 34; - for (int i = 0; i < 32; i += 1) { - if (i > 0 && i % 8 == 0) { - rep[cnt] = ' '; - cnt -= 1; - } - rep[cnt] = (x & 1) + '0'; - cnt -= 1; - x >>= 1; - } - rep[35] = '\0'; - return rep; -} - -void pb(uint32_t x) { - printf("%s : %d\n", utb(x), x); -} - -struct A { - int8_t a; - void *b; - int8_t c; - int16_t d; -}; - -struct B { - void *c; - double b; - int16_t a; -}; - -struct C { - int8_t a; - int8_t c; - int16_t d; - void *b; -}; - -// zaklada count > 0 -void secret(uint8_t *to, uint8_t *from, size_t count) { - size_t n = (count + 7) / 8; - switch (count % 8) { - case 0: do { *to++ = *from++; - case 7: *to++ = *from++; - case 6: *to++ = *from++; - case 5: *to++ = *from++; - case 4: *to++ = *from++; - case 3: *to++ = *from++; - case 2: *to++ = *from++; - case 1: *to++ = *from++; - } while (--n > 0); - } -} - -// zaklada count > 0 -void goto_secret(uint8_t *to, uint8_t *from, size_t count) { - size_t n = (count + 7) / 8; - static void *array[] = { &&finito, &&c0, &&c1, &&c2, &&c3, &&c4, &&c5, &&c6, &&c7 }; - goto *array[count % 8 + 1]; - c0: *to++ = *from++; - c7: *to++ = *from++; - c6: *to++ = *from++; - c5: *to++ = *from++; - c4: *to++ = *from++; - c3: *to++ = *from++; - c2: *to++ = *from++; - c1: *to++ = *from++; - goto *array[(--n > 0)]; - finito: return; -} - -int main() { - /* Zadanie 1 */ - printf("Zadanie 1:\n"); - - uint32_t i = 7, k = 15, x = 15689126; - - pb(x); - uint32_t c = (((1<> i) << k; // 0010 0000 - x = (x & ~(1<> 1) & B[0]); pb(c); - c = ((c >> S[1]) & B[1]) + (c & B[1]); pb(c); - c = ((c >> S[2]) + c) & B[2]; pb(c); - c = ((c >> S[3]) + c) & B[3]; pb(c); - c = ((c >> S[4]) + c) & B[4]; pb(c); - printf("-----------------\n"); - // wersja dla koksow - v = v - ((v >> 1) & 0x55555555); pb(v);// reuse input as temporary - v = ((v >> 2) & 0x33333333) + (v & 0x33333333); pb(v); // temp - c = ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; pb(c); // count - - - /* Zadanie 3 */ - printf("Zadanie 3:\n"); - - struct A a; - struct B b; - struct C d; - int8_t x1; - void *x2; - int16_t x3; - printf("%lu %lu %lu\n", sizeof x1, sizeof x2, sizeof x3); - printf("%lu %lu %lu\n", sizeof a, sizeof b, sizeof d); - - - /* Zadanie 4 */ - - - /* Zadanie 5 */ - - /* s += b[j + 1] + b[--j]; - * - * t1 := j + 1 - * t2 := t1 * 4 - * t3 := b[t2] - * j := j - 1 - * t4 := j * 4 - * t5 := b[t4] - * t6 := t4 + t5 // Czy na pewno tak? - * s := s + t6 - * - * a[i++] -= *b * (c[j*2] + 1); - * - * t1 := *b - * t2 := j * 2 - * t3 := t2 * 4 - * t4 := c[t3] - * t5 := t4 + 1 - * t6 := t1 * t5 - * a := a - t6 - * i := i + 1 - */ - - /* Zadanie 6 */ - /* vs->d = us[1].a + us[j].c; - * t1 := 1 * 12 - * t2 := us + t1 - * t2' := us + 0 // chcemy dostać się do a, ale jest na poczatku, wiec nic dodawac nie trzeba - * t3 := *t2 - * t4 := j * 12 - * t5 := us + t4 - * t6 := t5 + 8 - * t7 := *t6 - * t8 := t3 + t7 - * t9 := vs + 9 - * *t9 := t8 - */ - - /* Zadanie 7 */ - - /* I := 0 ; <> - goto ITest - ILoop: J := I ; <> - goto WTest - WLoop: t1 := 4 * J ; <> - Temp := arr[t1] ; arr[J] - t2 := J - 1 - t3 := 4 * t2 - t4 := arr[t3] ; arr[J - 1] - arr[t1] := t4 ; arr[J] := arr[J - 1] - arr[t3] := Temp ; arr[J - 1] := Temp - J := J - 1 - WTest: if J <= 0 goto IPlus ; <> - t4 := 4 * J ; <> - t5 := arr[t4] - t6 := J - 1 - t7 = 4 * t6 - t8 := arr[t7] - if t5 >= t8 goto IPlus - goto WLoop ; <> - IPlus: I := I + 1 ; <> - ITest: if I < length goto ILoop ; <> - */ - - - /* Zadanie 8 */ - printf("Zadanie 8:\n"); - - // secret kopiuje wartości na które wskazuje from do miejsca w które wskazuje to, - // przesuwa oba wskaźniki i powtarza tak count razy (czyli efektywnie kopiuje np. tablice) - - uint8_t t1[10] = {1,2,3,0,5,100,7,8,9,10}, t2[10]; - uint8_t* to = t2 + 2, *from = t1 + 3; - size_t count = 4; - - goto_secret(to, from, count); - - for (int i = 0; i < 10; i++) - printf("%hhd ", t1[i]); - printf("\n"); - for (int i = 0; i < 10; i++) - printf("%hhd ", t2[i]); - printf("\n"); - - i = 3; - t1[i++] = i; - printf("%hhd\n", t1[i-1]); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista1/test.c b/Semestr 4/ask/lista1/test.c deleted file mode 100644 index 0f3c11e..0000000 --- a/Semestr 4/ask/lista1/test.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -int main() -{ - int x; - short y; - x = -10; - y = (short)x; - printf("%d %hd", x, y); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista1/zad7.txt b/Semestr 4/ask/lista1/zad7.txt deleted file mode 100644 index 1e9c4b3..0000000 --- a/Semestr 4/ask/lista1/zad7.txt +++ /dev/null @@ -1,21 +0,0 @@ - I := 0 - goto ITest -ILoop: J := I - goto WTest -WLoop: t1 := 4 * J - Temp := arr[t1] - t2 := J - 1 - t3 := 4 * t2 - arr[t1] := arr[t3] - arr[t3] := Temp - J := J - 1 -WTest: if J <= 0 goto IPlus - t4 := 4 * J - t5 := arr[t4] - t6 := J - 1 - t7 = 4 * t6 - t8 := arr[t7] - if t5 >= t8 goto IPlus - goto WLoop -IPlus: I := I + 1 -ITest: if I < length goto ILoop \ No newline at end of file diff --git a/Semestr 4/ask/lista11/gen.py b/Semestr 4/ask/lista11/gen.py deleted file mode 100644 index d4de762..0000000 --- a/Semestr 4/ask/lista11/gen.py +++ /dev/null @@ -1,65 +0,0 @@ -def next_permutation(a): - """Generate the lexicographically next permutation inplace. - - https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order - Return false if there is no next permutation. - """ - # Find the largest index i such that a[i] < a[i + 1]. If no such - # index exists, the permutation is the last permutation - for i in reversed(range(len(a) - 1)): - if a[i] < a[i + 1]: - break # found - else: # no break: not found - return False # no next permutation - - # Find the largest index j greater than i such that a[i] < a[j] - j = next(j for j in reversed(range(i + 1, len(a))) if a[i] < a[j]) - - # Swap the value of a[i] with that of a[j] - a[i], a[j] = a[j], a[i] - - # Reverse sequence from a[i + 1] up to and including the final element a[n] - a[i + 1:] = reversed(a[i + 1:]) - return True - -def perm_to_str(a): - return ''.join(map(str, a)) - -def str_to_perm(s): - return [int(c) for c in s] - -t = [0,1,2,3] -perm_to_idx = dict() - -def bbin(x): - return bin(x)[2:] - -cnt = 23 -while True: - perm_to_idx[perm_to_str(t)] = cnt - cnt -= 1 - if not next_permutation(t): - break - -for p in perm_to_idx.keys(): - for i in range(4): - t = str_to_perm(p) - for j in range(4): - if t[j] > t[i]: - t[j] -= 1 - t[i] = 3 - print(p, 'x', i, '->', perm_to_str(t), ':\t', bbin(perm_to_idx[p]), '\t', bbin(i), '\t', bbin(perm_to_idx[perm_to_str(t)]), end='\t') - print(perm_to_idx[p], '\t', i, '\t', perm_to_idx[perm_to_str(t)]) - -print('\n-----\n') - - -for p in perm_to_idx.keys(): - for i in range(4): - t = str_to_perm(p) - for j in range(4): - if t[j] > t[i]: - t[j] -= 1 - t[i] = 3 - print(p, 'x', i, '->', perm_to_str(t), ':\t', bbin(perm_to_idx[p]), '\t', bbin(i), '\t', bbin(perm_to_idx[perm_to_str(t)]), end='\t') - print(perm_to_idx[p], '\t', i, '\t', perm_to_idx[perm_to_str(t)]) diff --git a/Semestr 4/ask/lista11/zad8.c b/Semestr 4/ask/lista11/zad8.c deleted file mode 100644 index cd8c2bf..0000000 --- a/Semestr 4/ask/lista11/zad8.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -uint8_t victim(uint8_t s) { - s |= ((s & 0x55) << 1) | (s & 0xaa >> 1); - return ((s >> 2) && 1) | ((s >> 4) && 2) | ((s >> 6) && 3); -} - -uint8_t update(uint8_t s, uint8_t v) { - int8_t p0 = victim(s); - int8_t p1 = victim(s ^ 0b01010101); - int8_t p2 = victim(s ^ 0b10101010); - int8_t p3 = victim(s ^ 0b11111111); - uint8_t age = (3 << (v << 1)) & s; - - s -= (~((char)(age - 1) >> 7)) & (1 << (p1 << 1)); - s -= (~((char)(age - 2) >> 7)) & (1 << (p2 << 1)); - s -= (~((char)(age - 3) >> 7)) & (1 << (p3 << 1)); - s |= (3 << (v << 1)); - return s; -} - -int main() {} \ No newline at end of file diff --git a/Semestr 4/ask/lista2/ask21_lista_2.pdf b/Semestr 4/ask/lista2/ask21_lista_2.pdf deleted file mode 100644 index e6df9d7..0000000 Binary files a/Semestr 4/ask/lista2/ask21_lista_2.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista2/pom.c b/Semestr 4/ask/lista2/pom.c deleted file mode 100644 index 87d542d..0000000 --- a/Semestr 4/ask/lista2/pom.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -char* utb(uint32_t x) { - static char rep[36]; - int cnt = 34; - for (int i = 0; i < 32; i += 1) { - if (i > 0 && i % 8 == 0) { - rep[cnt] = ' '; - cnt -= 1; - } - rep[cnt] = (x & 1) + '0'; - cnt -= 1; - x >>= 1; - } - rep[35] = '\0'; - return rep; -} - -void pb(uint32_t x) { - printf("%s : %d\n", utb(x), x); -} - -// int main() { -// /* Zadanie 1 */ - -// int32_t x; -// x = (1<<31); -// printf("%d, %d, %d %d\n", x, (x > 0), x-1, (x - 1 < 0)); -// } - -int main() { - /* Zadanie 1 */ - int32_t x; - scanf("%d", &x); - printf("%d %d\n", x*x, INT_MIN); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista3/ask21_lista_3.pdf b/Semestr 4/ask/lista3/ask21_lista_3.pdf deleted file mode 100644 index d83e9f8..0000000 Binary files a/Semestr 4/ask/lista3/ask21_lista_3.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista4/ask21_lista_4.pdf b/Semestr 4/ask/lista4/ask21_lista_4.pdf deleted file mode 100644 index 87e0e4a..0000000 Binary files a/Semestr 4/ask/lista4/ask21_lista_4.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista5/ask21_lista_5.pdf b/Semestr 4/ask/lista5/ask21_lista_5.pdf deleted file mode 100644 index b8c1977..0000000 Binary files a/Semestr 4/ask/lista5/ask21_lista_5.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista5/puzzle3.s b/Semestr 4/ask/lista5/puzzle3.s deleted file mode 100644 index f625752..0000000 --- a/Semestr 4/ask/lista5/puzzle3.s +++ /dev/null @@ -1,19 +0,0 @@ - .global puzzle3 - - .text -puzzle3: # rdi: n; rsi: d - movl %edi, %edi # zeruje 32 starsze bity rdi - salq $32, %rsi # rsi <<= 32 - movl $32, %edx # edx := 32 - movl $0x80000000, %ecx # ecx := MIN_INT - xorl %eax, %eax # eax := 0 -.L3: addq %rdi, %rdi # rdi *= 2 - movq %rdi, %r8 # r8 := rdi - subq %rsi, %r8 # r8 -= rsi - js .L2 # if r8 < 0 then jump to L2 - orl %ecx, %eax # eax |= ecx - movq %r8, %rdi # rdi := r8 -.L2: shrl %ecx # ecx >>= 1 - decl %edx # edx-- - jne .L3 # if (edx != 0) then jump to L3 - ret diff --git a/Semestr 4/ask/lista5/puzzle4.s b/Semestr 4/ask/lista5/puzzle4.s deleted file mode 100644 index 16ca386..0000000 --- a/Semestr 4/ask/lista5/puzzle4.s +++ /dev/null @@ -1,24 +0,0 @@ -.global puzzle4 - -.text -puzzle4: # argumenty: rdi - long*, rsi - long, rdx - uint64, rcx - uint64 - movq %rcx, %rax # rax := rcx - subq %rdx, %rax # rax -= rdx - shrq %rax # rax >>= 1; // ale logiczne! - addq %rdx, %rax # rax += rdx; - cmpq %rdx, %rcx # if rcx < rdx - jb .L5 # then jump to L5 - movq (%rdi,%rax,8), %r8 # r8 = *(rdi + 8*rax) - cmpq %rsi, %r8 # if rsi == r8 - je .L10 # then jump to L10 - cmpq %rsi, %r8 # if (r8 - rsi < 0) <=> r8 < rsi - jg .L11 # then jump to L11 - leaq 1(%rax), %rdx # rdx := rax + 1 - call puzzle4 # call recursively puzzle4 -.L10: ret # return rax -.L11: leaq -1(%rax), %rcx # rcx := rax - 1 - call puzzle4 # call recursively puzzle4 - ret # return rax -.L5: movl $-1, %eax # eax := -1 - ret # return rax - diff --git a/Semestr 4/ask/lista5/puzzle5.s b/Semestr 4/ask/lista5/puzzle5.s deleted file mode 100644 index 02c3aea..0000000 --- a/Semestr 4/ask/lista5/puzzle5.s +++ /dev/null @@ -1,24 +0,0 @@ -400590 : -400590: 48 83 subq $0x3c, %rsi # rsi -= 0x3c -400594: 48 83 fe 0 cmpq $0x5, %rsi # if rsi > 0x5 -400598: 77 29 ja *0x4005c3 # then jump to line 16 -40059a: ff 24 f5 f8 06 40 00 jmpq *0x4006f8(,%rsi,8) # jump to 19 + rsi -4005a1: 48 8d 04 fd 00 00 00 00 lea 0x0(,%rdi,8),%rax # rax := rdi * 8 -4005a9: c3 retq # return rax -4005aa: 48 89 f8 movq %rdi,%rax # rax := rdi -4005ad: 48 c1 f8 03 sarq $0x3,%rax # rax >>= 3 (arithmetic) -4005b1: c3 retq # return rax -4005b2: 48 89 f8 movq %rdi,%rax # rax := rdi -4005b5: 48 c1 e0 04 shlq $0x4,%rax # rax <<= 4 (logic) -4005b9: 48 29 f8 subq %rdi,%rax # rax -= rdi -4005bc: 48 89 c7 movq %rax,%rdi # rdi := rax -4005bf: 48 0f af ff imulq %rdi,%rdi # rdi *= rdi -4005c3: 48 8d 47 4b leaq 0x4b(%rdi),%rax # rax := 0x4b + rdi -4005c7: c3 retq # return rax - -0x4006f8: 0x4005a1 # line 6 -0x400700: 0x4005a1 # line 6 -0x400708: 0x4005b2 # line 11 -0x400710: 0x4005c3 # line 16 -0x400718: 0x4005aa # line 8 -0x400720: 0x4005bf # line 15 diff --git a/Semestr 4/ask/lista5/zad1.asm b/Semestr 4/ask/lista5/zad1.asm deleted file mode 100644 index 22aef29..0000000 --- a/Semestr 4/ask/lista5/zad1.asm +++ /dev/null @@ -1,15 +0,0 @@ -puzzle: testl %esi, %esi - je .L4 ; jesli esi == 0, skocz do L4 - xorl %edx, %edx ; edx := 0 - xorl %eax, %eax ; eax := 0 -.L3: movl %edi, %ecx ; ecx := edi - andl $1, %ecx ; ecx &= 1 - addl %ecx, %eax ; eax += eax - sarq %rdi ; rdi >>= 1 - incl %edx, ; edx++ - cmpl %edx, %esi ; edx - esi != 0? <=> edx != esi - jne .L3 ; jesli tak, skocz do L3 - ret -.L4 movl %esi, %eax ; return esi - ret - diff --git a/Semestr 4/ask/lista5/zad1.c b/Semestr 4/ask/lista5/zad1.c deleted file mode 100644 index 9379bb2..0000000 --- a/Semestr 4/ask/lista5/zad1.c +++ /dev/null @@ -1,25 +0,0 @@ -#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 diff --git a/Semestr 4/ask/lista5/zad1.s b/Semestr 4/ask/lista5/zad1.s deleted file mode 100644 index b935b9e..0000000 --- a/Semestr 4/ask/lista5/zad1.s +++ /dev/null @@ -1,98 +0,0 @@ - .file "zad1.c" - .text - .p2align 4 - .globl puzzle - .type puzzle, @function -puzzle: -.LFB23: - .cfi_startproc - endbr64 - xorl %r8d, %r8d - testl %esi, %esi - je .L1 - xorl %eax, %eax - .p2align 4,,10 - .p2align 3 -.L3: - movl %edi, %edx - addl $1, %eax - sarq %rdi - andl $1, %edx - addl %edx, %r8d - cmpl %esi, %eax - jne .L3 -.L1: - movl %r8d, %eax - ret - .cfi_endproc -.LFE23: - .size puzzle, .-puzzle - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "%ld%u" - .section .text.startup,"ax",@progbits - .p2align 4 - .globl main - .type main, @function -main: -.LFB24: - .cfi_startproc - endbr64 - subq $40, %rsp - .cfi_def_cfa_offset 48 - leaq .LC0(%rip), %rdi - movq %fs:40, %rax - movq %rax, 24(%rsp) - xorl %eax, %eax - leaq 12(%rsp), %rdx - leaq 16(%rsp), %rsi - call __isoc99_scanf@PLT - movl 12(%rsp), %ecx - movq 16(%rsp), %rax - xorl %r8d, %r8d - testl %ecx, %ecx - je .L8 - xorl %edx, %edx - .p2align 4,,10 - .p2align 3 -.L10: - movl %eax, %esi - addl $1, %edx - sarq %rax - andl $1, %esi - addl %esi, %r8d - cmpl %ecx, %edx - jne .L10 -.L8: - movq 24(%rsp), %rax - xorq %fs:40, %rax - jne .L16 - movl %r8d, %eax - addq $40, %rsp - .cfi_remember_state - .cfi_def_cfa_offset 8 - ret -.L16: - .cfi_restore_state - call __stack_chk_fail@PLT - .cfi_endproc -.LFE24: - .size main, .-main - .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" - .section .note.GNU-stack,"",@progbits - .section .note.gnu.property,"a" - .align 8 - .long 1f - 0f - .long 4f - 1f - .long 5 -0: - .string "GNU" -1: - .align 8 - .long 0xc0000002 - .long 3f - 2f -2: - .long 0x3 -3: - .align 8 -4: diff --git a/Semestr 4/ask/lista5/zad2.asm b/Semestr 4/ask/lista5/zad2.asm deleted file mode 100644 index 7fe4364..0000000 --- a/Semestr 4/ask/lista5/zad2.asm +++ /dev/null @@ -1,15 +0,0 @@ -puzzle2: - movq %rdi, %rax ; rax := rdi -.L3: movb (%rax), %r9b ; r9b := *rax - leaq 1(%rax), %r8 ; r8 := rax + 1 - movq %rsi, %rdx ; rdx := *rsi -.L2: movb (%rdx), %cl ; cl := *rdx - incq %rdx ; rdx++ - testb %cl, %cl ; if (cl == 0) - je .L4 ; then jump to L4 - cmpb %cl, %r9b ; if (cl != r9b) - jne .L2 ; then jump to L2 - movq %r8, %rax ; rax := r8 - jmp .L3 ; jump to L3 -.L4 subq %rdi, %rax ; rax -= rdi - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista5/zad2.c b/Semestr 4/ask/lista5/zad2.c deleted file mode 100644 index ab9cb54..0000000 --- a/Semestr 4/ask/lista5/zad2.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include - -long puzzle2(char *rdi /* rdi */, char *rsi /* rsi */) { - char *rax = rdi; -L3: - char r9b = *rax; - char *r8 = rax + 1; - char *rdx = rsi; -L2: - char cl = *rdx; - rdx++; - if (cl == 0) { - goto L4; - } - if (cl != r9b) { - goto L2; - } - rax = r8; - goto L3; -L4: - return rax - rdi; -} - - -// funkcja sprawdza jaka jest pierwsza litera z s która nie występuje w d -// jesli wszystkie występują, to zwróci długość s. -long puzzle2_decoded(char *s /* rdi */, char *d /* rsi */) { - for (char *result = s ; ; result++) { - char first = *result; - char *crawl = d; - for (char *crawl = d; *crawl != first; crawl++) { - if (*crawl == 0) { - return result - s; - } - } - } -} - - - -int main() { - -} \ No newline at end of file diff --git a/Semestr 4/ask/lista5/zad3.c b/Semestr 4/ask/lista5/zad3.c deleted file mode 100644 index 1ce9067..0000000 --- a/Semestr 4/ask/lista5/zad3.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -uint32_t puzzle3(uint32_t n, uint32_t d); - -// uint32_t divv(uint32_t edi, uint32_t esi) { -// uint64_t rdi = edi; -// uint64_t rsi = esi; -// rsi <<= 32; -// uint8_t edx = 32; -// uint32_t ecx = 0x80000000; -// uint32_t eax = 0; -// L3: -// rdi += rdi; -// int64_t r8 = rdi; -// r8 -= rsi; -// if (r8 < 0) { -// goto L2; -// } -// eax |= ecx; -// rdi = r8; -// L2: -// ecx >>= 1; -// edx--; -// if (edx != 0) { -// goto L3; -// } -// return eax; -// } - -uint32_t decoded(uint32_t n, uint32_t d) { - uint64_t N = n; - uint64_t D = (uint64_t)d << 32; - - uint32_t bit = 0x80000000; - uint32_t result = 0; - for (uint32_t edx = 32; edx > 0; edx--) { - N += N; - if ((int64_t)(N - D) >= 0) { - result |= bit; - N -= D; - } - bit >>= 1; - } - return result; -} - -int main() { - for (uint32_t n=0; n <= 1000; ++n) { - for (uint32_t d=1; d <= 1000; ++d) { - if (puzzle3(n,d) != decoded(n, d)) { - printf("%d %d\n", n, d); - printf("%u %u\n", puzzle3(n, d), decoded(n, d)); - return 0; - } - } - } - printf("%d\n", puzzle3(1000000000, 2)); -} \ No newline at end of file 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 -#include -#include - -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 diff --git a/Semestr 4/ask/lista5/zad5.c b/Semestr 4/ask/lista5/zad5.c deleted file mode 100644 index c1fe957..0000000 --- a/Semestr 4/ask/lista5/zad5.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include - -long switch_prob(long rdi, long rsi) { - static void *array[] = { &&L1, &&L1, &&L2, &&L3, &&L4, &&L5 }; - long rax; - rsi -= 0x3c; - if (rsi > 0x5) { - goto L3; - } - goto *array[rsi]; -L1: - rax = rdi * 8; - return rax; -L4: - rax = rdi; - rax >>= 3; - retun rax; -L2: - rax = rdi; - rax <<= 4; - rax -= rdi; - rdi = rax; -L5: - rdi *= rdi; -L3: - rax = 0x4b + rdi; - return rax; -} - -long decode(long x, long n) { - long result; - n -= 0x3c; - switch (n) - { - case 0: - case 1: - return x + 8; - case 4: - return x >> 3; - case 2: - result = (x << 4) - x; - x = result; - case 5: - x *= x; - case 3: - default: - return 0x4b + x; - } -} - -int main() { - -} \ No newline at end of file diff --git a/Semestr 4/ask/lista6/puzzle.c b/Semestr 4/ask/lista6/puzzle.c deleted file mode 100644 index 6a18d20..0000000 --- a/Semestr 4/ask/lista6/puzzle.c +++ /dev/null @@ -1,28 +0,0 @@ -```c= - 0: 55 pushq %rbp - 1: 48 89 e5 movq %rsp, %rbp - 4: 48 83 ec 10 subq $16, %rsp - 8: 48 89 e0 movq %rsp, %rax #wsk stosu to rax - b: 48 8d 0c fd 0f 00 00 00 leaq 15(,%rdi,8), %rcx #n * rozmiar longa + 15 do rcx (+15 to kwestia wyrównania/sufit) - 13: 48 83 e1 f0 andq $-16, %rcx #zerujemy ostatnie 4 bity - 17: 48 29 c8 subq %rcx, %rax #oblicz nowy wskaźnik stosu - 1a: 48 89 c4 movq %rax, %rsp #nowy wskaźnik wrzuć do rsp - 1d: 48 8d 4d f8 leaq -8(%rbp), %rcx - 21: 48 89 4c f8 f8 movq %rcx, -8(%rax,%rdi,8) - 26: 48 c7 45 f8 00 00 00 00 movq $0, -8(%rbp) - 2e: 48 85 ff testq %rdi, %rdi - 31: 7e 1d jle 29 <_aframe+0x50> - 33: 31 c9 xorl %ecx, %ecx - 35: 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax) - 3f: 90 nop - 40: 48 89 14 c8 movq %rdx, (%rax,%rcx,8) - 44: 48 ff c1 incq %rcx - 47: 48 39 cf cmpq %rcx, %rdi - 4a: 75 f4 jne -12 <_aframe+0x40> - 4c: 48 89 7d f8 movq %rdi, -8(%rbp) - 50: 48 8b 04 f0 movq (%rax,%rsi,8), %rax - 54: 48 8b 00 movq (%rax), %rax - 57: 48 89 ec movq %rbp, %rsp #powrót do poprzedniej ramki - 5a: 5d popq %rbp #wrzucenie do rbp poprzedniego adresu - 5b: c3 retq -``` \ No newline at end of file diff --git a/Semestr 4/ask/lista6/puzzle.s b/Semestr 4/ask/lista6/puzzle.s deleted file mode 100644 index 3a39398..0000000 --- a/Semestr 4/ask/lista6/puzzle.s +++ /dev/null @@ -1,22 +0,0 @@ - .globl puzzle - - .text -puzzle: - push %rbp # adres koncu ramki, callee-saved - xorl %eax, %eax # zeruje %rax - mov %rsi, %rbp # rbp := rsi, czyli rbp := p - push %rbx # rbx na stos, callee-saved - mov %rdi, %rbx # rbx := rdi, czyli rbx := n - sub $24, %rsp # rsp -= 24, czyli przesun rsp o 3 bajty w dół - test %rdi, %rdi # rdi == 0?, czyli n == 0? - jle .L1 # jesli tak, skocz do L1 - lea 8(%rsp), %rsi # w p.w. rsi := rsp + 8 - lea (%rdi,%rdi), %rdi # rdi := 2*rdi - call puzzle # wywolanie rekurencyjne puzzle - add 8(%rsp), %rax # rax := rax + *(rsp + 8) - add %rax, %rbx # rbx := rbx + rax -.L1: mov %rbx, (%rbp) # *rbp := rbx, czyli *p := rbx - add $24, %rsp # rsp := rsp + 24 (przesun adres stacka o 3 bajty) - pop %rbx # przywracamy rbx - pop %rbp # przywracamy rbp - ret diff --git a/Semestr 4/ask/lista6/puzzle7.s b/Semestr 4/ask/lista6/puzzle7.s deleted file mode 100644 index 6d26961..0000000 --- a/Semestr 4/ask/lista6/puzzle7.s +++ /dev/null @@ -1,29 +0,0 @@ - .global puzzle7 - - .text -puzzle7: - movq %rsi, -40(%rsp) - movq %rdx, -32(%rsp) - movq %rcx, -24(%rsp) - movq %r8, -16(%rsp) - movq %r9, -8(%rsp) - movl $8, -72(%rsp) - leaq 8(%rsp), %rax - movq %rax, -64(%rsp) - leaq -48(%rsp), %rax - movq %rax, -56(%rsp) - movl $0, %eax - jmp .L2 -.L3: movq -64(%rsp), %rdx - leaq 8(%rdx), %rcx - movq %rcx, -64(%rsp) -.L4: addq (%rdx), %rax -.L2: subq $1, %rdi - js .L6 - cmpl $47, -72(%rsp) - ja .L3 - movl -72(%rsp), %edx - addq -56(%rsp), %rdx - addl $8, -72(%rsp) - jmp .L4 -.L6: ret diff --git a/Semestr 4/ask/lista6/puzzle8.c b/Semestr 4/ask/lista6/puzzle8.c deleted file mode 100644 index 4d65f9d..0000000 --- a/Semestr 4/ask/lista6/puzzle8.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -struct T { - long min; - long max; - long mean; -}; - -struct T puzzle8(long *a, long n); - -struct T decode(long *a, long n) { - long maks = LONG_MIN; - long mini = LONG_MAX; - long sum = 0; - for (int i = 0; i < n; i++) { - if (maks < a[i]) maks = a[i]; - if (mini > a[i]) mini = a[i]; - sum += a[i]; - } - struct T ret; - ret.min = mini; - ret.max = maks; - ret.mean = sum / n; - return ret; -} \ No newline at end of file diff --git a/Semestr 4/ask/lista6/puzzle8.s b/Semestr 4/ask/lista6/puzzle8.s deleted file mode 100644 index cc3805d..0000000 --- a/Semestr 4/ask/lista6/puzzle8.s +++ /dev/null @@ -1,30 +0,0 @@ -# rdi - adres zwracanej struktury (niejawnie) -# rsi - *a -# rdx - n - - .global puzzle8 - - .text -puzzle8: - movq %rdx, %r11 # r11 := n - xorl %r10d, %r10d # r10 := 0 - xorl %eax, %eax # rax := 0 - movq $LONG_MIN, %r8 # r8 := 0x800... - movq $LONG_MAX, %r9 # r9 := 0x7ff... -.L2: cmpq %r11, %r10 # if n <= r10 - jge .L5 # then jump to L5, else - movq (%rsi,%r10,8), %rcx # rcx := a[r10] - cmpq %rcx, %r9 # if a[r10] < r9 - cmovg %rcx, %r9 # then r9 = a[r10] - cmpq %rcx, %r8 # if a[r10] > r8 - cmovl %rcx, %r8 # then r8 = a[r10] - addq %rcx, %rax # rax += a[r10] - incq %r10 # r10++ - jmp .L2 -.L5: cqto # jeśli rax < 0 to niech rdx zaplonie - movq %r9, (%rdi) # rdi->0 := r9 - idivq %r11 # podziel rax przez r11, efektywnie rax /= r11 - movq %r8, 8(%rdi) # rdi->8 := r8 - movq %rax, 16(%rdi) # rdi->16 := rax - movq %rdi, %rax # rax := rdi - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista6/test.c b/Semestr 4/ask/lista6/test.c deleted file mode 100644 index 8a84ac2..0000000 --- a/Semestr 4/ask/lista6/test.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -int main() { - int32_t x = 0xc0000000; - int32_t y = x + x; - - printf("%d, %d\n", x, y); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista6/zad7.c b/Semestr 4/ask/lista6/zad7.c deleted file mode 100644 index 9072504..0000000 --- a/Semestr 4/ask/lista6/zad7.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -int wypisuj(int cnt, ...) { - va_list v; - va_start(v, cnt); - int sum = 0; - for (int i = 0; i < cnt; i++) { - sum += va_arg(v, int); - } - return sum; -} - -int puzzle7(int cnt, ...); - -int main() { - printf("%d\n", puzzle7(10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista7/eval.s b/Semestr 4/ask/lista7/eval.s deleted file mode 100644 index f7340a0..0000000 --- a/Semestr 4/ask/lista7/eval.s +++ /dev/null @@ -1,18 +0,0 @@ - .global eval - - .text -eval: - movq %rdi, %rax - movq 16(%rsp), %rcx - movq 24(%rsp), %rdx - movq (%rdx), %rsi - movq %rcx, %rdx - imulq %rsi, %rdx - movq %rdx, (%rdi) - movq 8(%rsp), %rdx - movq %rdx, %rdi - subq %rsi, %rdi - movq %rdi, 8(%rax) - subq %rcx, %rdx - movq %rdx, 16(%rax) - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista7/wrap.s b/Semestr 4/ask/lista7/wrap.s deleted file mode 100644 index 6f01dfc..0000000 --- a/Semestr 4/ask/lista7/wrap.s +++ /dev/null @@ -1,18 +0,0 @@ - .global wrap - - .text -wrap: - subq $72, %rsp - movq %rdx, (%rsp) - movq %rsp, %rdx - leaq 8(%rsp), %rax - pushq %rdx - pushq %rsi - pushq %rdi - movq %rax, %rdi - call eval - movq 40(%rsp), %rax - addq 32(%rsp), %rax - imulq 48(%rsp), %rax - addq $96, %rsp - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista7/zad5.c b/Semestr 4/ask/lista7/zad5.c deleted file mode 100644 index d65cb4f..0000000 --- a/Semestr 4/ask/lista7/zad5.c +++ /dev/null @@ -1,38 +0,0 @@ -#include - -typedef struct A { - long u[2]; - long *v; -} SA; - -typedef struct B { - long p[2]; - long q; -} SB; - -SB eval(SA s); -long wrap(long x, long y, long z); - -SB eval_decoded(SA a) { - SB ret; - ret.p[0] = a.u[1] * (*a.v); - ret.p[1] = a.u[0] - (*a.v); - ret.q = a.u[0] - a.u[1]; - return ret; -} - -long wrap_decoded(long x, long y, long z) { - SA a; - a.v = &z; - a.u[0] = x; - a.u[1] = y; - SB b = eval_decoded(a); - long result = (b.p[1] + b.p[0]) * b.q; - return result; -} - -int main() { - printf("%ld\n", wrap(15, 16, 17)); - printf("%ld\n", wrap_decoded(15, 16, 17)); - return 0; -} \ No newline at end of file diff --git a/Semestr 4/ask/lista7/zad5.s b/Semestr 4/ask/lista7/zad5.s deleted file mode 100644 index e69de29..0000000 diff --git a/Semestr 4/ask/lista7/zad7.cpp b/Semestr 4/ask/lista7/zad7.cpp deleted file mode 100644 index 073224f..0000000 --- a/Semestr 4/ask/lista7/zad7.cpp +++ /dev/null @@ -1,19 +0,0 @@ -struct Base { - Base(int n) : data(n) {} - int data; - virtual int doit(int n) { return n - data; } -}; -struct Derived : Base { - Derived(int n) : Base(n + 1) {} - int doit(int n) { return n * data; } -}; - -int doit(Base *bp) { - return bp->doit(1); -} - -int main(int argc, char *argv[]) { - Base b = Base(10); - Derived d = Derived(20); - return doit(&b) + doit(&d); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista7/zad7.ll b/Semestr 4/ask/lista7/zad7.ll deleted file mode 100644 index a99e8d8..0000000 --- a/Semestr 4/ask/lista7/zad7.ll +++ /dev/null @@ -1,174 +0,0 @@ -; ModuleID = 'zad7.cpp' -source_filename = "zad7.cpp" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-linux-gnu" - -%struct.Base = type <{ i32 (...)**, i32, [4 x i8] }> -%struct.Derived = type { %struct.Base.base, [4 x i8] } -%struct.Base.base = type <{ i32 (...)**, i32 }> - -$_ZN4BaseC1Ei = comdat any - -$_ZN7DerivedC1Ei = comdat any - -$_ZN4BaseC2Ei = comdat any - -$_ZN4Base4doitEi = comdat any - -$_ZN7DerivedC2Ei = comdat any - -$_ZN7Derived4doitEi = comdat any - -$_ZTV4Base = comdat any - -$_ZTS4Base = comdat any - -$_ZTI4Base = comdat any - -$_ZTV7Derived = comdat any - -$_ZTS7Derived = comdat any - -$_ZTI7Derived = comdat any - -@_ZTV4Base = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI4Base to i8*), i8* bitcast (i32 (%struct.Base*, i32)* @_ZN4Base4doitEi to i8*)] }, comdat, align 8 -@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* -@_ZTS4Base = linkonce_odr constant [6 x i8] c"4Base\00", comdat, align 1 -@_ZTI4Base = linkonce_odr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Base, i32 0, i32 0) }, comdat, align 8 -@_ZTV7Derived = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI7Derived to i8*), i8* bitcast (i32 (%struct.Derived*, i32)* @_ZN7Derived4doitEi to i8*)] }, comdat, align 8 -@_ZTVN10__cxxabiv120__si_class_type_infoE = external global i8* -@_ZTS7Derived = linkonce_odr constant [9 x i8] c"7Derived\00", comdat, align 1 -@_ZTI7Derived = linkonce_odr constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @_ZTS7Derived, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI4Base to i8*) }, comdat, align 8 - -; Function Attrs: noinline nounwind optnone -define i32 @_Z4doitP4Base(%struct.Base* %bp) #0 { -entry: - %bp.addr = alloca %struct.Base*, align 8 - store %struct.Base* %bp, %struct.Base** %bp.addr, align 8 - %0 = load %struct.Base*, %struct.Base** %bp.addr, align 8 - %1 = bitcast %struct.Base* %0 to i32 (%struct.Base*, i32)*** - %vtable = load i32 (%struct.Base*, i32)**, i32 (%struct.Base*, i32)*** %1, align 8 - %vfn = getelementptr inbounds i32 (%struct.Base*, i32)*, i32 (%struct.Base*, i32)** %vtable, i64 0 - %2 = load i32 (%struct.Base*, i32)*, i32 (%struct.Base*, i32)** %vfn, align 8 - %call = call i32 %2(%struct.Base* %0, i32 1) - ret i32 %call -} - -; Function Attrs: noinline norecurse nounwind optnone -define i32 @main(i32 %argc, i8** %argv) #1 { -entry: - %retval = alloca i32, align 4 - %argc.addr = alloca i32, align 4 - %argv.addr = alloca i8**, align 8 - %b = alloca %struct.Base, align 8 - %d = alloca %struct.Derived, align 8 - store i32 0, i32* %retval, align 4 - store i32 %argc, i32* %argc.addr, align 4 - store i8** %argv, i8*** %argv.addr, align 8 - call void @_ZN4BaseC1Ei(%struct.Base* %b, i32 10) - call void @_ZN7DerivedC1Ei(%struct.Derived* %d, i32 20) - %call = call i32 @_Z4doitP4Base(%struct.Base* %b) - %0 = bitcast %struct.Derived* %d to %struct.Base* - %call1 = call i32 @_Z4doitP4Base(%struct.Base* %0) - %add = add nsw i32 %call, %call1 - ret i32 %add -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN4BaseC1Ei(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Base*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Base* %this, %struct.Base** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - call void @_ZN4BaseC2Ei(%struct.Base* %this1, i32 %0) - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN7DerivedC1Ei(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Derived*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - call void @_ZN7DerivedC2Ei(%struct.Derived* %this1, i32 %0) - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN4BaseC2Ei(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Base*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Base* %this, %struct.Base** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 - %0 = bitcast %struct.Base* %this1 to i32 (...)*** - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Base, i32 0, inrange i32 0, i32 2) to i32 (...)**), i32 (...)*** %0, align 8 - %data = getelementptr inbounds %struct.Base, %struct.Base* %this1, i32 0, i32 1 - %1 = load i32, i32* %n.addr, align 4 - store i32 %1, i32* %data, align 8 - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr i32 @_ZN4Base4doitEi(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Base*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Base* %this, %struct.Base** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - %data = getelementptr inbounds %struct.Base, %struct.Base* %this1, i32 0, i32 1 - %1 = load i32, i32* %data, align 8 - %sub = sub nsw i32 %0, %1 - ret i32 %sub -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN7DerivedC2Ei(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Derived*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 - %0 = bitcast %struct.Derived* %this1 to %struct.Base* - %1 = load i32, i32* %n.addr, align 4 - %add = add nsw i32 %1, 1 - call void @_ZN4BaseC2Ei(%struct.Base* %0, i32 %add) - %2 = bitcast %struct.Derived* %this1 to i32 (...)*** - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV7Derived, i32 0, inrange i32 0, i32 2) to i32 (...)**), i32 (...)*** %2, align 8 - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr i32 @_ZN7Derived4doitEi(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Derived*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - %1 = bitcast %struct.Derived* %this1 to %struct.Base* - %data = getelementptr inbounds %struct.Base, %struct.Base* %1, i32 0, i32 1 - %2 = load i32, i32* %data, align 8 - %mul = mul nsw i32 %0, %2 - ret i32 %mul -} - -attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.module.flags = !{!0} -!llvm.ident = !{!1} - -!0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{!"clang version 10.0.0-4ubuntu1 "} diff --git a/Semestr 4/ask/lista8/._lista_8 b/Semestr 4/ask/lista8/._lista_8 deleted file mode 100755 index 893436c..0000000 Binary files a/Semestr 4/ask/lista8/._lista_8 and /dev/null differ diff --git a/Semestr 4/ask/lista8/ask21_lista_8.tgz b/Semestr 4/ask/lista8/ask21_lista_8.tgz deleted file mode 100644 index 789c9af..0000000 Binary files a/Semestr 4/ask/lista8/ask21_lista_8.tgz and /dev/null differ diff --git a/Semestr 4/ask/lista8/bar.c b/Semestr 4/ask/lista8/bar.c deleted file mode 100644 index 97fbd4f..0000000 --- a/Semestr 4/ask/lista8/bar.c +++ /dev/null @@ -1,5 +0,0 @@ -// extern long foo; - -int bar = 42; -// long *foo_p = &foo; -short dead[15]; diff --git a/Semestr 4/ask/lista8/even.c b/Semestr 4/ask/lista8/even.c deleted file mode 100644 index 5bf8606..0000000 --- a/Semestr 4/ask/lista8/even.c +++ /dev/null @@ -1,8 +0,0 @@ -int is_odd(long n); - -int is_even(long n) { - if (n == 0) - return 1; - else - return is_odd(n - 1); -} diff --git a/Semestr 4/ask/lista8/foo.c b/Semestr 4/ask/lista8/foo.c deleted file mode 100644 index 080d831..0000000 --- a/Semestr 4/ask/lista8/foo.c +++ /dev/null @@ -1,5 +0,0 @@ -// extern int bar; - -long foo = 19; -// int *bar_p = &bar; -char code[17]; diff --git a/Semestr 4/ask/lista8/lazy.c b/Semestr 4/ask/lista8/lazy.c deleted file mode 100644 index fb08cf7..0000000 --- a/Semestr 4/ask/lista8/lazy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(void) { - puts("first time"); - puts("second time"); - return 0; -} diff --git a/Semestr 4/ask/lista8/main.lds b/Semestr 4/ask/lista8/main.lds deleted file mode 100644 index 25a4ca9..0000000 --- a/Semestr 4/ask/lista8/main.lds +++ /dev/null @@ -1,39 +0,0 @@ -OUTPUT_FORMAT("elf64-x86-64") -OUTPUT_ARCH(i386:x86-64) -ENTRY(_start) -PHDRS -{ - code PT_LOAD FLAGS(5); - rodata PT_LOAD FLAGS(4); - data PT_LOAD FLAGS(6); -} -SECTIONS -{ - . = 0x400000 + SIZEOF_HEADERS; - - .text : - { - *(.text .text.*) - } : code - - .rodata : - { - *(.rodata .rodata.*) - } : rodata - - .data : - { - *(.data .data.*) - } : data - - .bss : - { - *(.bss .bss.*) - *(COMMON) - } : data - - /DISCARD/ : - { - *(.note.gnu.property) - } -} diff --git a/Semestr 4/ask/lista8/merge-1.map b/Semestr 4/ask/lista8/merge-1.map deleted file mode 100644 index 2e93e7c..0000000 --- a/Semestr 4/ask/lista8/merge-1.map +++ /dev/null @@ -1,300 +0,0 @@ - -Merging program properties - - -Discarded input sections - - .note.gnu.property - 0x0000000000000000 0x20 bar.o - -Memory Configuration - -Name Origin Length Attributes -*default* 0x0000000000000000 0xffffffffffffffff - -Linker script and memory map - -LOAD foo.o -LOAD bar.o - -.interp - *(.interp) - -.note.gnu.property - 0x0000000000000000 0x20 - .note.gnu.property - 0x0000000000000000 0x20 foo.o - -.note.gnu.build-id - *(.note.gnu.build-id) - -.hash - *(.hash) - -.gnu.hash - *(.gnu.hash) - -.dynsym - *(.dynsym) - -.dynstr - *(.dynstr) - -.gnu.version - *(.gnu.version) - -.gnu.version_d - *(.gnu.version_d) - -.gnu.version_r - *(.gnu.version_r) - -.rela.init - *(.rela.init) - -.rela.text - *(.rela.text) - -.rela.fini - *(.rela.fini) - -.rela.rodata - *(.rela.rodata) - -.rela.data.rel.ro - *(.rela.data.rel.ro) - -.rela.data - *(.rela.data) - -.rela.tdata - *(.rela.tdata) - -.rela.tbss - *(.rela.tbss) - -.rela.ctors - *(.rela.ctors) - -.rela.dtors - *(.rela.dtors) - -.rela.got - *(.rela.got) - -.rela.bss - *(.rela.bss) - -.rela.ldata - *(.rela.ldata) - -.rela.lbss - *(.rela.lbss) - -.rela.lrodata - *(.rela.lrodata) - -.rela.ifunc - *(.rela.ifunc) - -.rela.plt - *(.rela.plt) - -.init - *(SORT_NONE(.init)) - -.plt - *(.plt) - -.plt.got - *(.plt.got) - -.plt.sec - *(.plt.sec) - -.text 0x0000000000000000 0x0 - *(.text .stub) - .text 0x0000000000000000 0x0 foo.o - .text 0x0000000000000000 0x0 bar.o - *(.gnu.warning) - -.fini - *(SORT_NONE(.fini)) - -.rodata - *(.rodata) - -.rodata1 - *(.rodata1) - -.eh_frame_hdr - *(.eh_frame_hdr) - -.eh_frame - *(.eh_frame) - -.gcc_except_table - *(.gcc_except_table) - -.gnu_extab - *(.gnu_extab*) - -.exception_ranges - *(.exception_ranges) - -.eh_frame - *(.eh_frame) - -.gnu_extab - *(.gnu_extab) - -.gcc_except_table - *(.gcc_except_table) - -.exception_ranges - *(.exception_ranges) - -.tdata - *(.tdata) - -.tbss - *(.tbss) - -.jcr - *(.jcr) - -.dynamic - *(.dynamic) - -.got - *(.got) - -.got.plt - *(.got.plt) - -.data 0x0000000000000000 0xc - *(.data) - .data 0x0000000000000000 0x8 foo.o - 0x0000000000000000 foo - .data 0x0000000000000008 0x4 bar.o - 0x0000000000000008 bar - -.data1 - *(.data1) - -.bss 0x0000000000000000 0x3e - *(.bss) - .bss 0x0000000000000000 0x11 foo.o - 0x0000000000000000 code - *fill* 0x0000000000000011 0xf - .bss 0x0000000000000020 0x1e bar.o - 0x0000000000000020 dead - -.lbss - *(.lbss) - -.lrodata - *(.lrodata) - -.ldata - *(.ldata) - -.stab - *(.stab) - -.stabstr - *(.stabstr) - -.stab.excl - *(.stab.excl) - -.stab.exclstr - *(.stab.exclstr) - -.stab.index - *(.stab.index) - -.stab.indexstr - *(.stab.indexstr) - -.comment 0x0000000000000000 0x56 - *(.comment) - .comment 0x0000000000000000 0x2b foo.o - .comment 0x000000000000002b 0x2b bar.o - -.note.GNU-stack - 0x0000000000000000 0x0 - .note.GNU-stack - 0x0000000000000000 0x0 foo.o - .note.GNU-stack - 0x0000000000000000 0x0 bar.o - -.gnu.build.attributes - *(.gnu.build.attributes) - -.debug - *(.debug) - -.line - *(.line) - -.debug_srcinfo - *(.debug_srcinfo) - -.debug_sfnames - *(.debug_sfnames) - -.debug_aranges - *(.debug_aranges) - -.debug_pubnames - *(.debug_pubnames) - -.debug_info - *(.debug_info) - -.debug_abbrev - *(.debug_abbrev) - -.debug_line - *(.debug_line) - -.debug_frame - *(.debug_frame) - -.debug_str - *(.debug_str) - -.debug_loc - *(.debug_loc) - -.debug_macinfo - *(.debug_macinfo) - -.debug_weaknames - *(.debug_weaknames) - -.debug_funcnames - *(.debug_funcnames) - -.debug_typenames - *(.debug_typenames) - -.debug_varnames - *(.debug_varnames) - -.debug_pubtypes - *(.debug_pubtypes) - -.debug_ranges - *(.debug_ranges) - -.debug_macro - *(.debug_macro) - -.debug_addr - *(.debug_addr) - -.gnu.attributes - *(.gnu.attributes) -OUTPUT(merge-1.o elf64-x86-64) diff --git a/Semestr 4/ask/lista8/merge-2.map b/Semestr 4/ask/lista8/merge-2.map deleted file mode 100644 index 2677803..0000000 --- a/Semestr 4/ask/lista8/merge-2.map +++ /dev/null @@ -1,301 +0,0 @@ - -Merging program properties - - -Discarded input sections - - .note.gnu.property - 0x0000000000000000 0x20 foo.o - -Memory Configuration - -Name Origin Length Attributes -*default* 0x0000000000000000 0xffffffffffffffff - -Linker script and memory map - -LOAD bar.o -LOAD foo.o - -.interp - *(.interp) - -.note.gnu.property - 0x0000000000000000 0x20 - .note.gnu.property - 0x0000000000000000 0x20 bar.o - -.note.gnu.build-id - *(.note.gnu.build-id) - -.hash - *(.hash) - -.gnu.hash - *(.gnu.hash) - -.dynsym - *(.dynsym) - -.dynstr - *(.dynstr) - -.gnu.version - *(.gnu.version) - -.gnu.version_d - *(.gnu.version_d) - -.gnu.version_r - *(.gnu.version_r) - -.rela.init - *(.rela.init) - -.rela.text - *(.rela.text) - -.rela.fini - *(.rela.fini) - -.rela.rodata - *(.rela.rodata) - -.rela.data.rel.ro - *(.rela.data.rel.ro) - -.rela.data - *(.rela.data) - -.rela.tdata - *(.rela.tdata) - -.rela.tbss - *(.rela.tbss) - -.rela.ctors - *(.rela.ctors) - -.rela.dtors - *(.rela.dtors) - -.rela.got - *(.rela.got) - -.rela.bss - *(.rela.bss) - -.rela.ldata - *(.rela.ldata) - -.rela.lbss - *(.rela.lbss) - -.rela.lrodata - *(.rela.lrodata) - -.rela.ifunc - *(.rela.ifunc) - -.rela.plt - *(.rela.plt) - -.init - *(SORT_NONE(.init)) - -.plt - *(.plt) - -.plt.got - *(.plt.got) - -.plt.sec - *(.plt.sec) - -.text 0x0000000000000000 0x0 - *(.text .stub) - .text 0x0000000000000000 0x0 bar.o - .text 0x0000000000000000 0x0 foo.o - *(.gnu.warning) - -.fini - *(SORT_NONE(.fini)) - -.rodata - *(.rodata) - -.rodata1 - *(.rodata1) - -.eh_frame_hdr - *(.eh_frame_hdr) - -.eh_frame - *(.eh_frame) - -.gcc_except_table - *(.gcc_except_table) - -.gnu_extab - *(.gnu_extab*) - -.exception_ranges - *(.exception_ranges) - -.eh_frame - *(.eh_frame) - -.gnu_extab - *(.gnu_extab) - -.gcc_except_table - *(.gcc_except_table) - -.exception_ranges - *(.exception_ranges) - -.tdata - *(.tdata) - -.tbss - *(.tbss) - -.jcr - *(.jcr) - -.dynamic - *(.dynamic) - -.got - *(.got) - -.got.plt - *(.got.plt) - -.data 0x0000000000000000 0x10 - *(.data) - .data 0x0000000000000000 0x4 bar.o - 0x0000000000000000 bar - *fill* 0x0000000000000004 0x4 - .data 0x0000000000000008 0x8 foo.o - 0x0000000000000008 foo - -.data1 - *(.data1) - -.bss 0x0000000000000000 0x31 - *(.bss) - .bss 0x0000000000000000 0x1e bar.o - 0x0000000000000000 dead - *fill* 0x000000000000001e 0x2 - .bss 0x0000000000000020 0x11 foo.o - 0x0000000000000020 code - -.lbss - *(.lbss) - -.lrodata - *(.lrodata) - -.ldata - *(.ldata) - -.stab - *(.stab) - -.stabstr - *(.stabstr) - -.stab.excl - *(.stab.excl) - -.stab.exclstr - *(.stab.exclstr) - -.stab.index - *(.stab.index) - -.stab.indexstr - *(.stab.indexstr) - -.comment 0x0000000000000000 0x56 - *(.comment) - .comment 0x0000000000000000 0x2b bar.o - .comment 0x000000000000002b 0x2b foo.o - -.note.GNU-stack - 0x0000000000000000 0x0 - .note.GNU-stack - 0x0000000000000000 0x0 bar.o - .note.GNU-stack - 0x0000000000000000 0x0 foo.o - -.gnu.build.attributes - *(.gnu.build.attributes) - -.debug - *(.debug) - -.line - *(.line) - -.debug_srcinfo - *(.debug_srcinfo) - -.debug_sfnames - *(.debug_sfnames) - -.debug_aranges - *(.debug_aranges) - -.debug_pubnames - *(.debug_pubnames) - -.debug_info - *(.debug_info) - -.debug_abbrev - *(.debug_abbrev) - -.debug_line - *(.debug_line) - -.debug_frame - *(.debug_frame) - -.debug_str - *(.debug_str) - -.debug_loc - *(.debug_loc) - -.debug_macinfo - *(.debug_macinfo) - -.debug_weaknames - *(.debug_weaknames) - -.debug_funcnames - *(.debug_funcnames) - -.debug_typenames - *(.debug_typenames) - -.debug_varnames - *(.debug_varnames) - -.debug_pubtypes - *(.debug_pubtypes) - -.debug_ranges - *(.debug_ranges) - -.debug_macro - *(.debug_macro) - -.debug_addr - *(.debug_addr) - -.gnu.attributes - *(.gnu.attributes) -OUTPUT(merge-2.o elf64-x86-64) diff --git a/Semestr 4/ask/lista8/mismatch-a.c b/Semestr 4/ask/lista8/mismatch-a.c deleted file mode 100644 index 39436f2..0000000 --- a/Semestr 4/ask/lista8/mismatch-a.c +++ /dev/null @@ -1,7 +0,0 @@ -/* mismatch-a.c */ -void p2(void); - -int main() { - p2(); - return 0; -} diff --git a/Semestr 4/ask/lista8/mismatch-b.c b/Semestr 4/ask/lista8/mismatch-b.c deleted file mode 100644 index 451d5b3..0000000 --- a/Semestr 4/ask/lista8/mismatch-b.c +++ /dev/null @@ -1,8 +0,0 @@ -/* mismatch-b.c */ -#include - -char main; - -void p2() { - printf("0x%x\n", main); -} diff --git a/Semestr 4/ask/lista8/odd.c b/Semestr 4/ask/lista8/odd.c deleted file mode 100644 index c32961e..0000000 --- a/Semestr 4/ask/lista8/odd.c +++ /dev/null @@ -1,8 +0,0 @@ -int is_even(long n); - -int is_odd(long n) { - if (n == 0) - return 0; - else - return is_even(n - 1); -} diff --git a/Semestr 4/ask/lista8/relo3.c b/Semestr 4/ask/lista8/relo3.c deleted file mode 100644 index 6aca7b6..0000000 --- a/Semestr 4/ask/lista8/relo3.c +++ /dev/null @@ -1,15 +0,0 @@ -int relo3(int val) { - switch (val) { - case 100: - return val; - case 101: - return val + 1; - case 103: - case 104: - return val + 3; - case 105: - return val + 5; - default: - return val + 6; - } -} diff --git a/Semestr 4/ask/lista8/start.c b/Semestr 4/ask/lista8/start.c deleted file mode 100644 index a875ace..0000000 --- a/Semestr 4/ask/lista8/start.c +++ /dev/null @@ -1,8 +0,0 @@ -int is_even(long); - -void _start(void) { - asm volatile( - "syscall" - : /* no output */ - : "a" (0x3c), "D" (is_even(42))); -} diff --git a/Semestr 4/ask/lista8/str-a.c b/Semestr 4/ask/lista8/str-a.c deleted file mode 100644 index 3b0fb36..0000000 --- a/Semestr 4/ask/lista8/str-a.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -char *somestr(void); - -int main(void) { - char *s = somestr(); - s[5] = '\0'; - puts(s); - return 0; -} diff --git a/Semestr 4/ask/lista8/str-b.c b/Semestr 4/ask/lista8/str-b.c deleted file mode 100644 index 50101cb..0000000 --- a/Semestr 4/ask/lista8/str-b.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -char *somestr(void) { - char *buf = malloc(sizeof("Hello, world!")); - strcpy(buf, "Hello, world!"); - return buf; -} - diff --git a/Semestr 4/ask/lista8/swap.c b/Semestr 4/ask/lista8/swap.c deleted file mode 100644 index e1966fd..0000000 --- a/Semestr 4/ask/lista8/swap.c +++ /dev/null @@ -1,18 +0,0 @@ -extern int buf[]; - -int *bufp0 = &buf[0]; -static int *bufp1; - -static void incr() { - static int count = 0; - count++; -} - -void swap() { - int temp; - incr(); - bufp1 = &buf[1]; - temp = *bufp0; - *bufp0 = *bufp1; - *bufp1 = temp; -} diff --git a/Semestr 4/ask/lista9/gadget.s b/Semestr 4/ask/lista9/gadget.s deleted file mode 100644 index 6d60a63..0000000 --- a/Semestr 4/ask/lista9/gadget.s +++ /dev/null @@ -1,16 +0,0 @@ - .global gadget - - .text - -# rax: 0x3c -# rdi: 0 -# rdx: {NULL, ...} -# rsi: path + '\n' -gadget: - dec %rax # rax: 0x3c -> 0x3b (sys_execve) - mov %rdx, %rsi # rsi: argv = {NULL} - mov %rdi, %rdx # rdx: envp = NULL - lea 16(%rsp),%rdi # rdi: path - ret - -# vim: ft=gas diff --git a/Semestr 4/ask/lista9/lazy.c b/Semestr 4/ask/lista9/lazy.c deleted file mode 100644 index fb08cf7..0000000 --- a/Semestr 4/ask/lista9/lazy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(void) { - puts("first time"); - puts("second time"); - return 0; -} diff --git a/Semestr 4/ask/lista9/lista_9.tgz b/Semestr 4/ask/lista9/lista_9.tgz deleted file mode 100644 index 5e5c6f4..0000000 Binary files a/Semestr 4/ask/lista9/lista_9.tgz and /dev/null differ diff --git a/Semestr 4/ask/lista9/relo3.c b/Semestr 4/ask/lista9/relo3.c deleted file mode 100644 index 6aca7b6..0000000 --- a/Semestr 4/ask/lista9/relo3.c +++ /dev/null @@ -1,15 +0,0 @@ -int relo3(int val) { - switch (val) { - case 100: - return val; - case 101: - return val + 1; - case 103: - case 104: - return val + 3; - case 105: - return val + 5; - default: - return val + 6; - } -} diff --git a/Semestr 4/ask/lista9/ropex.c b/Semestr 4/ask/lista9/ropex.c deleted file mode 100644 index dbeae12..0000000 --- a/Semestr 4/ask/lista9/ropex.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -/* Get string from stdin */ -void readline(FILE *in, char *p) { - int c; - while (true) { - c = fgetc(in); - if (c == EOF || c == '\n') - break; - *p++ = c; - } - *p = '\0'; -} - -void echo(FILE *in) { - char buf[48]; - readline(in, buf); - puts(buf); -} - -int main(int argc, char *argv[]) { - FILE *in = NULL; - if (argc == 2) - in = fopen(argv[1], "rb"); - if (in == NULL) - in = stdin; - echo(in); - return 0; -} diff --git a/Semestr 4/ask/lista9/ropex.in (1).txt b/Semestr 4/ask/lista9/ropex.in (1).txt deleted file mode 100644 index 902773e..0000000 --- a/Semestr 4/ask/lista9/ropex.in (1).txt +++ /dev/null @@ -1,7 +0,0 @@ -00000000: dead c0de dead c0de dead c0de dead c0de ................ -00000010: dead c0de dead c0de dead c0de dead c0de ................ -00000020: dead c0de dead c0de dead c0de dead c0de ................ -00000030: dead c0de dead c0de 731c 4000 0000 0000 ................ -00000040: f422 4000 0000 0000 0000 0000 0000 0000 ................ -00000050: 2f75 7372 2f62 696e 2f70 7974 686f 6e32 /usr/bin/python2 -00000060: 000a ................ diff --git a/Semestr 4/ask/lista9/ropex.in.txt b/Semestr 4/ask/lista9/ropex.in.txt deleted file mode 100644 index 8deabfe..0000000 --- a/Semestr 4/ask/lista9/ropex.in.txt +++ /dev/null @@ -1,7 +0,0 @@ -00000000: dead c0de dead c0de dead c0de dead c0de ................ -00000010: dead c0de dead c0de dead c0de dead c0de ................ -00000020: dead c0de dead c0de dead c0de dead c0de ................ -00000030: dead c0de dead c0de 671d 4000 0000 0000 ................ -00000040: 8e44 4900 0000 0000 0000 0000 0000 0000 ................ -00000050: 2f75 7372 2f62 696e 2f6e 7961 6e63 6174 /usr/bin/nyancat -00000060: 000a ................ \ No newline at end of file diff --git a/Semestr 4/ask/lista9/ropex.map b/Semestr 4/ask/lista9/ropex.map deleted file mode 100644 index 4bd12a5..0000000 --- a/Semestr 4/ask/lista9/ropex.map +++ /dev/null @@ -1,511 +0,0 @@ -Archive member included to satisfy reference by file (symbol) - -/usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (__libc_csu_init) - -Merging program properties - -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (0x3) and gadget.o (not found) -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) (0x3) -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o (0x3) -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o (0x3) - -As-needed library included to satisfy reference by file (symbol) - -libc.so.6 ropex.o (fopen@@GLIBC_2.2.5) - -Discarded input sections - - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .note.GNU-stack - 0x0000000000000000 0x0 ropex.o - .note.gnu.property - 0x0000000000000000 0x20 ropex.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - -Memory Configuration - -Name Origin Length Attributes -*default* 0x0000000000000000 0xffffffffffffffff - -Linker script and memory map - -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -LOAD ropex.o -LOAD gadget.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc_s.so -START GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libgcc_s.so.1 -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -END GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libc.so -START GROUP -LOAD /lib/x86_64-linux-gnu/libc.so.6 -LOAD /usr/lib/x86_64-linux-gnu/libc_nonshared.a -LOAD /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -END GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc_s.so -START GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libgcc_s.so.1 -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -END GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - [!provide] PROVIDE (__executable_start = SEGMENT_START ("text-segment", 0x0)) - 0x00000000000002a8 . = (SEGMENT_START ("text-segment", 0x0) + SIZEOF_HEADERS) - -.interp 0x00000000000002a8 0x1c - *(.interp) - .interp 0x00000000000002a8 0x1c /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.note.gnu.build-id - 0x00000000000002c4 0x24 - *(.note.gnu.build-id) - .note.gnu.build-id - 0x00000000000002c4 0x24 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.note.ABI-tag 0x00000000000002e8 0x20 - .note.ABI-tag 0x00000000000002e8 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.hash - *(.hash) - -.gnu.hash 0x0000000000000308 0x28 - *(.gnu.hash) - .gnu.hash 0x0000000000000308 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.dynsym 0x0000000000000330 0x108 - *(.dynsym) - .dynsym 0x0000000000000330 0x108 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.dynstr 0x0000000000000438 0xaf - *(.dynstr) - .dynstr 0x0000000000000438 0xaf /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.gnu.version 0x00000000000004e8 0x16 - *(.gnu.version) - .gnu.version 0x00000000000004e8 0x16 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.gnu.version_d 0x0000000000000500 0x0 - *(.gnu.version_d) - .gnu.version_d - 0x0000000000000500 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.gnu.version_r 0x0000000000000500 0x30 - *(.gnu.version_r) - .gnu.version_r - 0x0000000000000500 0x30 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.rela.dyn 0x0000000000000530 0xd8 - *(.rela.init) - *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) - .rela.text 0x0000000000000530 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.fini) - *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) - *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) - .rela.data.rel.ro - 0x0000000000000530 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .rela.data.rel.local - 0x0000000000000530 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) - *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) - *(.rela.ctors) - *(.rela.dtors) - *(.rela.got) - .rela.got 0x0000000000000548 0x78 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) - .rela.bss 0x00000000000005c0 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) - *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) - *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) - *(.rela.ifunc) - .rela.ifunc 0x00000000000005d8 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .rela.fini_array - 0x00000000000005d8 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .rela.init_array - 0x00000000000005f0 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.rela.plt 0x0000000000000608 0x60 - *(.rela.plt) - .rela.plt 0x0000000000000608 0x60 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.iplt) - 0x0000000000001000 . = ALIGN (CONSTANT (MAXPAGESIZE)) - -.init 0x0000000000001000 0x1b - *(SORT_NONE(.init)) - .init 0x0000000000001000 0x16 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - 0x0000000000001000 _init - .init 0x0000000000001016 0x5 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - -.plt 0x0000000000001020 0x50 - *(.plt) - .plt 0x0000000000001020 0x50 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000001030 puts@@GLIBC_2.2.5 - 0x0000000000001040 __stack_chk_fail@@GLIBC_2.4 - 0x0000000000001050 fgetc@@GLIBC_2.2.5 - 0x0000000000001060 fopen@@GLIBC_2.2.5 - *(.iplt) - -.plt.got 0x0000000000001070 0x8 - *(.plt.got) - .plt.got 0x0000000000001070 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000001070 __cxa_finalize@@GLIBC_2.2.5 - -.plt.sec - *(.plt.sec) - -.text 0x0000000000001080 0x235 - *(.text.unlikely .text.*_unlikely .text.unlikely.*) - *(.text.exit .text.exit.*) - *(.text.startup .text.startup.*) - *(.text.hot .text.hot.*) - *(SORT_BY_NAME(.text.sorted.*)) - *(.text .stub .text.* .gnu.linkonce.t.*) - .text 0x0000000000001080 0x2f /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000001080 _start - .text 0x00000000000010af 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - *fill* 0x00000000000010af 0x1 - .text 0x00000000000010b0 0xb9 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .text 0x0000000000001169 0xbb ropex.o - 0x0000000000001169 readline - 0x00000000000011a3 echo - 0x00000000000011e7 main - .text 0x0000000000001224 0xf gadget.o - 0x0000000000001224 gadget - *fill* 0x0000000000001233 0xd - .text 0x0000000000001240 0x75 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - 0x0000000000001240 __libc_csu_init - 0x00000000000012b0 __libc_csu_fini - .text 0x00000000000012b5 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .text 0x00000000000012b5 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - *(.gnu.warning) - -.fini 0x00000000000012b8 0xd - *(SORT_NONE(.fini)) - .fini 0x00000000000012b8 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - 0x00000000000012b8 _fini - .fini 0x00000000000012c0 0x5 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - [!provide] PROVIDE (__etext = .) - [!provide] PROVIDE (_etext = .) - [!provide] PROVIDE (etext = .) - 0x0000000000002000 . = ALIGN (CONSTANT (MAXPAGESIZE)) - 0x0000000000002000 . = SEGMENT_START ("rodata-segment", (ALIGN (CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 0x1)))) - -.rodata 0x0000000000002000 0x7 - *(.rodata .rodata.* .gnu.linkonce.r.*) - .rodata.cst4 0x0000000000002000 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000002000 _IO_stdin_used - .rodata.str1.1 - 0x0000000000002004 0x3 ropex.o - -.rodata1 - *(.rodata1) - -.eh_frame_hdr 0x0000000000002008 0x34 - *(.eh_frame_hdr) - .eh_frame_hdr 0x0000000000002008 0x34 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000002008 __GNU_EH_FRAME_HDR - *(.eh_frame_entry .eh_frame_entry.*) - -.eh_frame 0x0000000000002040 0xd0 - *(.eh_frame) - .eh_frame 0x0000000000002040 0x30 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x2c (size before relaxing) - *fill* 0x0000000000002070 0x0 - .eh_frame 0x0000000000002070 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x40 (size before relaxing) - .eh_frame 0x0000000000002098 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x30 (size before relaxing) - .eh_frame 0x00000000000020b0 0x5c /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - 0x78 (size before relaxing) - .eh_frame 0x000000000000210c 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - *(.eh_frame.*) - -.gcc_except_table - *(.gcc_except_table .gcc_except_table.*) - -.gnu_extab - *(.gnu_extab*) - -.exception_ranges - *(.exception_ranges*) - 0x0000000000003da0 . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)) - -.eh_frame - *(.eh_frame) - *(.eh_frame.*) - -.gnu_extab - *(.gnu_extab) - -.gcc_except_table - *(.gcc_except_table .gcc_except_table.*) - -.exception_ranges - *(.exception_ranges*) - -.tdata 0x0000000000003da0 0x0 - [!provide] PROVIDE (__tdata_start = .) - *(.tdata .tdata.* .gnu.linkonce.td.*) - -.tbss - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - -.preinit_array 0x0000000000003da0 0x0 - [!provide] PROVIDE (__preinit_array_start = .) - *(.preinit_array) - [!provide] PROVIDE (__preinit_array_end = .) - -.init_array 0x0000000000003da0 0x8 - 0x0000000000003da0 PROVIDE (__init_array_start = .) - *(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)) - *(.init_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) .ctors) - .init_array 0x0000000000003da0 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - 0x0000000000003da8 PROVIDE (__init_array_end = .) - -.fini_array 0x0000000000003da8 0x8 - [!provide] PROVIDE (__fini_array_start = .) - *(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)) - *(.fini_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) .dtors) - .fini_array 0x0000000000003da8 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - [!provide] PROVIDE (__fini_array_end = .) - -.ctors - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT_BY_NAME(.ctors.*)) - *(.ctors) - -.dtors - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT_BY_NAME(.dtors.*)) - *(.dtors) - -.jcr - *(.jcr) - -.data.rel.ro 0x0000000000003db0 0x0 - *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) - *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) - .data.rel.ro 0x0000000000003db0 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.dynamic 0x0000000000003db0 0x1f0 - *(.dynamic) - .dynamic 0x0000000000003db0 0x1f0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000003db0 _DYNAMIC - -.got 0x0000000000003fa0 0x60 - *(.got.plt) - .got.plt 0x0000000000003fa0 0x38 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000003fa0 _GLOBAL_OFFSET_TABLE_ - *(.igot.plt) - *(.got) - .got 0x0000000000003fd8 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.igot) - 0x0000000000004000 . = DATA_SEGMENT_RELRO_END (., 0x0) - -.data 0x0000000000004000 0x10 - *(.data .data.* .gnu.linkonce.d.*) - .data 0x0000000000004000 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000004000 data_start - 0x0000000000004000 __data_start - .data 0x0000000000004004 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .data 0x0000000000004004 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - *fill* 0x0000000000004004 0x4 - .data.rel.local - 0x0000000000004008 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - 0x0000000000004008 __dso_handle - .data 0x0000000000004010 0x0 ropex.o - .data 0x0000000000004010 0x0 gadget.o - .data 0x0000000000004010 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .data 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .data 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - -.tm_clone_table - 0x0000000000004010 0x0 - .tm_clone_table - 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .tm_clone_table - 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - -.data1 - *(.data1) - 0x0000000000004010 _edata = . - [!provide] PROVIDE (edata = .) - 0x0000000000004010 . = . - 0x0000000000004010 __bss_start = . - -.bss 0x0000000000004010 0x10 - *(.dynbss) - *fill* 0x0000000000004010 0x0 - .dynbss 0x0000000000004010 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000004010 stdin@@GLIBC_2.2.5 - *(.bss .bss.* .gnu.linkonce.b.*) - .bss 0x0000000000004018 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .bss 0x0000000000004018 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .bss 0x0000000000004018 0x1 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .bss 0x0000000000004019 0x0 ropex.o - .bss 0x0000000000004019 0x0 gadget.o - .bss 0x0000000000004019 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .bss 0x0000000000004019 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .bss 0x0000000000004019 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - *(COMMON) - 0x0000000000004020 . = ALIGN ((. != 0x0)?0x8:0x1) - *fill* 0x0000000000004019 0x7 - -.lbss - *(.dynlbss) - *(.lbss .lbss.* .gnu.linkonce.lb.*) - *(LARGE_COMMON) - 0x0000000000004020 . = ALIGN (0x8) - 0x0000000000004020 . = SEGMENT_START ("ldata-segment", .) - -.lrodata - *(.lrodata .lrodata.* .gnu.linkonce.lr.*) - -.ldata 0x0000000000006020 0x0 - *(.ldata .ldata.* .gnu.linkonce.l.*) - 0x0000000000006020 . = ALIGN ((. != 0x0)?0x8:0x1) - 0x0000000000006020 . = ALIGN (0x8) - 0x0000000000004020 _end = . - [!provide] PROVIDE (end = .) - 0x0000000000006020 . = DATA_SEGMENT_END (.) - -.stab - *(.stab) - -.stabstr - *(.stabstr) - -.stab.excl - *(.stab.excl) - -.stab.exclstr - *(.stab.exclstr) - -.stab.index - *(.stab.index) - -.stab.indexstr - *(.stab.indexstr) - -.comment 0x0000000000000000 0x2a - *(.comment) - .comment 0x0000000000000000 0x2a /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - 0x2b (size before relaxing) - .comment 0x000000000000002a 0x2b ropex.o - .comment 0x000000000000002a 0x2b /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - -.gnu.build.attributes - *(.gnu.build.attributes .gnu.build.attributes.*) - -.debug - *(.debug) - -.line - *(.line) - -.debug_srcinfo - *(.debug_srcinfo) - -.debug_sfnames - *(.debug_sfnames) - -.debug_aranges 0x0000000000000000 0x30 - *(.debug_aranges) - .debug_aranges - 0x0000000000000000 0x30 ropex.o - -.debug_pubnames - *(.debug_pubnames) - -.debug_info 0x0000000000000000 0x49e - *(.debug_info .gnu.linkonce.wi.*) - .debug_info 0x0000000000000000 0x49e ropex.o - -.debug_abbrev 0x0000000000000000 0x19b - *(.debug_abbrev) - .debug_abbrev 0x0000000000000000 0x19b ropex.o - -.debug_line 0x0000000000000000 0x188 - *(.debug_line .debug_line.* .debug_line_end) - .debug_line 0x0000000000000000 0x188 ropex.o - -.debug_frame 0x0000000000000000 0xa8 - *(.debug_frame) - .debug_frame 0x0000000000000000 0xa8 ropex.o - -.debug_str 0x0000000000000000 0x2f4 - *(.debug_str) - .debug_str 0x0000000000000000 0x2f4 ropex.o - 0x333 (size before relaxing) - -.debug_loc 0x0000000000000000 0x254 - *(.debug_loc) - .debug_loc 0x0000000000000000 0x254 ropex.o - -.debug_macinfo - *(.debug_macinfo) - -.debug_weaknames - *(.debug_weaknames) - -.debug_funcnames - *(.debug_funcnames) - -.debug_typenames - *(.debug_typenames) - -.debug_varnames - *(.debug_varnames) - -.debug_pubtypes - *(.debug_pubtypes) - -.debug_ranges - *(.debug_ranges) - -.debug_macro - *(.debug_macro) - -.debug_addr - *(.debug_addr) - -.gnu.attributes - *(.gnu.attributes) - -/DISCARD/ - *(.note.GNU-stack) - *(.gnu_debuglink) - *(.gnu.lto_*) -OUTPUT(ropex elf64-x86-64) diff --git a/Semestr 4/ask/lista9/test.c b/Semestr 4/ask/lista9/test.c deleted file mode 100644 index 1dae111..0000000 --- a/Semestr 4/ask/lista9/test.c +++ /dev/null @@ -1,7 +0,0 @@ -void foobar() {} - -static const struct { - char a[3]; int b; long c; float pi; -} baz = { "abc", 42, -3, 1.4142 }; - -long array[100]; \ No newline at end of file diff --git a/Semestr 4/ask/lista9/test.s b/Semestr 4/ask/lista9/test.s deleted file mode 100644 index 5e60585..0000000 --- a/Semestr 4/ask/lista9/test.s +++ /dev/null @@ -1,50 +0,0 @@ - .file "test.c" - .text - .globl foobar - .type foobar, @function -foobar: -.LFB0: - .cfi_startproc - endbr64 - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - nop - popq %rbp - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE0: - .size foobar, .-foobar - .section .rodata - .align 16 - .type baz, @object - .size baz, 24 -baz: - .ascii "abc" - .zero 1 - .long 42 - .quad -3 - .long 1068827777 - .zero 4 - .comm array,800,32 - .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" - .section .note.GNU-stack,"",@progbits - .section .note.gnu.property,"a" - .align 8 - .long 1f - 0f - .long 4f - 1f - .long 5 -0: - .string "GNU" -1: - .align 8 - .long 0xc0000002 - .long 3f - 2f -2: - .long 0x3 -3: - .align 8 -4: diff --git "a/Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" "b/Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" deleted file mode 100644 index ee8e221..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" "b/Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" deleted file mode 100644 index b847b14..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" "b/Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" deleted file mode 100644 index 61cb028..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/hackersdelight.pdf" "b/Semestr 4/ask/materia\305\202y/hackersdelight.pdf" deleted file mode 100644 index 9f0003f..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/hackersdelight.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" "b/Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" deleted file mode 100644 index 3133054..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" "b/Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" deleted file mode 100644 index 2a5a923..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" and /dev/null differ diff --git a/Semestr 4/ask/zadanie1/rozw.c b/Semestr 4/ask/zadanie1/rozw.c deleted file mode 100644 index 068a268..0000000 --- a/Semestr 4/ask/zadanie1/rozw.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -const uint64_t C[] = { - 0x5555555555555555LL, - 0x3333333333333333LL, - 0x0f0f0f0f0f0f0f0fLL, - 0x00ff00ff00ff00ffLL, - 0x0000ffff0000ffffLL, - 0x00000000ffffffffLL -}; - -uint64_t revbits(uint64_t x) { - x = ((x & C[0]) << 1) | ((x >> 1) & C[0]); - x = ((x & C[1]) << 2) | ((x >> 2) & C[1]); - x = ((x & C[2]) << 4) | ((x >> 4) & C[2]); - x = ((x & C[3]) << 8) | ((x >> 8) & C[3]); - x = ((x & C[4]) << 16) | ((x >> 16) & C[4]); - x = ((x & C[5]) << 32) | ((x >> 32) & C[5]); - return x; -} \ No newline at end of file diff --git a/Semestr 4/pstwo/kol1/FranciszekMalinkaKolokwium1.pdf b/Semestr 4/pstwo/kol1/FranciszekMalinkaKolokwium1.pdf deleted file mode 100644 index 82c38f7..0000000 Binary files a/Semestr 4/pstwo/kol1/FranciszekMalinkaKolokwium1.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista1/L1Z4.pdf b/Semestr 4/pstwo/lista1/L1Z4.pdf deleted file mode 100644 index 6fe5c29..0000000 Binary files a/Semestr 4/pstwo/lista1/L1Z4.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista1/RP1R_01.pdf b/Semestr 4/pstwo/lista1/RP1R_01.pdf deleted file mode 100644 index ecce64c..0000000 Binary files a/Semestr 4/pstwo/lista1/RP1R_01.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista10/L10.pdf b/Semestr 4/pstwo/lista10/L10.pdf deleted file mode 100644 index abe2ff9..0000000 Binary files a/Semestr 4/pstwo/lista10/L10.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista10/RP1R_10.pdf b/Semestr 4/pstwo/lista10/RP1R_10.pdf deleted file mode 100644 index 26374ca..0000000 Binary files a/Semestr 4/pstwo/lista10/RP1R_10.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista2/L2Z11.pdf b/Semestr 4/pstwo/lista2/L2Z11.pdf deleted file mode 100644 index bf6f8d3..0000000 Binary files a/Semestr 4/pstwo/lista2/L2Z11.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista2/RP1R_02.pdf b/Semestr 4/pstwo/lista2/RP1R_02.pdf deleted file mode 100644 index 1deaa87..0000000 Binary files a/Semestr 4/pstwo/lista2/RP1R_02.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista3/L3Z4.pdf b/Semestr 4/pstwo/lista3/L3Z4.pdf deleted file mode 100644 index 59a2004..0000000 Binary files a/Semestr 4/pstwo/lista3/L3Z4.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista3/RP1R_03.pdf b/Semestr 4/pstwo/lista3/RP1R_03.pdf deleted file mode 100644 index 164c2cd..0000000 Binary files a/Semestr 4/pstwo/lista3/RP1R_03.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista4/L4Z15.pdf b/Semestr 4/pstwo/lista4/L4Z15.pdf deleted file mode 100644 index 4aaed16..0000000 Binary files a/Semestr 4/pstwo/lista4/L4Z15.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista4/RP1R_04.pdf b/Semestr 4/pstwo/lista4/RP1R_04.pdf deleted file mode 100644 index a093a1b..0000000 Binary files a/Semestr 4/pstwo/lista4/RP1R_04.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista5/L5Z12.pdf b/Semestr 4/pstwo/lista5/L5Z12.pdf deleted file mode 100644 index 7d0d438..0000000 Binary files a/Semestr 4/pstwo/lista5/L5Z12.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista5/RP1R_05.pdf b/Semestr 4/pstwo/lista5/RP1R_05.pdf deleted file mode 100644 index 6ba1d4c..0000000 Binary files a/Semestr 4/pstwo/lista5/RP1R_05.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista6/L6Z13.pdf b/Semestr 4/pstwo/lista6/L6Z13.pdf deleted file mode 100644 index bb2f02d..0000000 Binary files a/Semestr 4/pstwo/lista6/L6Z13.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista6/RP1R_06.pdf b/Semestr 4/pstwo/lista6/RP1R_06.pdf deleted file mode 100644 index d2297f2..0000000 Binary files a/Semestr 4/pstwo/lista6/RP1R_06.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista7/RP1R_07.pdf b/Semestr 4/pstwo/lista7/RP1R_07.pdf deleted file mode 100644 index f159bf0..0000000 Binary files a/Semestr 4/pstwo/lista7/RP1R_07.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista8/RP1R_08.pdf b/Semestr 4/pstwo/lista8/RP1R_08.pdf deleted file mode 100644 index 6a5140e..0000000 Binary files a/Semestr 4/pstwo/lista8/RP1R_08.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista9/RP1R_09.pdf b/Semestr 4/pstwo/lista9/RP1R_09.pdf deleted file mode 100644 index 5baaf9f..0000000 Binary files a/Semestr 4/pstwo/lista9/RP1R_09.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/lista9/l9z3.pdf b/Semestr 4/pstwo/lista9/l9z3.pdf deleted file mode 100644 index 784523f..0000000 Binary files a/Semestr 4/pstwo/lista9/l9z3.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 10.pdf b/Semestr 4/pstwo/wyklady/Wyklad 10.pdf deleted file mode 100644 index 1224e18..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 10.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 11.pdf b/Semestr 4/pstwo/wyklady/Wyklad 11.pdf deleted file mode 100644 index c5611dd..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 11.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 12.pdf b/Semestr 4/pstwo/wyklady/Wyklad 12.pdf deleted file mode 100644 index a7572be..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 12.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 2.pdf b/Semestr 4/pstwo/wyklady/Wyklad 2.pdf deleted file mode 100644 index df38730..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 2.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 3.pdf b/Semestr 4/pstwo/wyklady/Wyklad 3.pdf deleted file mode 100644 index 32e902d..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 3.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 4.pdf b/Semestr 4/pstwo/wyklady/Wyklad 4.pdf deleted file mode 100644 index a368c05..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 4.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 5.pdf b/Semestr 4/pstwo/wyklady/Wyklad 5.pdf deleted file mode 100644 index 7085970..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 5.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 7.pdf b/Semestr 4/pstwo/wyklady/Wyklad 7.pdf deleted file mode 100644 index 60156c8..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 7.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 8.pdf b/Semestr 4/pstwo/wyklady/Wyklad 8.pdf deleted file mode 100644 index a635d14..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 8.pdf and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/Wyklad 9.pdf b/Semestr 4/pstwo/wyklady/Wyklad 9.pdf deleted file mode 100644 index 5c0e798..0000000 Binary files a/Semestr 4/pstwo/wyklady/Wyklad 9.pdf and /dev/null differ diff --git "a/Semestr 4/pstwo/wyklady/Wyk\305\202ad 1.pdf" "b/Semestr 4/pstwo/wyklady/Wyk\305\202ad 1.pdf" deleted file mode 100644 index d04dccd..0000000 Binary files "a/Semestr 4/pstwo/wyklady/Wyk\305\202ad 1.pdf" and /dev/null differ diff --git "a/Semestr 4/pstwo/wyklady/Wyk\305\202ad 6.pdf" "b/Semestr 4/pstwo/wyklady/Wyk\305\202ad 6.pdf" deleted file mode 100644 index a011254..0000000 Binary files "a/Semestr 4/pstwo/wyklady/Wyk\305\202ad 6.pdf" and /dev/null differ diff --git a/Semestr 4/pstwo/wyklady/w1.svg b/Semestr 4/pstwo/wyklady/w1.svg deleted file mode 100644 index 701e596..0000000 --- a/Semestr 4/pstwo/wyklady/w1.svg +++ /dev/null @@ -1,4229 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Semestr 4/rr1r/kol1/kol1.xopp b/Semestr 4/rr1r/kol1/kol1.xopp deleted file mode 100644 index b7bd15e..0000000 Binary files a/Semestr 4/rr1r/kol1/kol1.xopp and /dev/null differ diff --git a/Semestr 4/rr1r/kol1/zad1.pdf b/Semestr 4/rr1r/kol1/zad1.pdf deleted file mode 100644 index 6f142b3..0000000 Binary files a/Semestr 4/rr1r/kol1/zad1.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/kol1/zad2.pdf b/Semestr 4/rr1r/kol1/zad2.pdf deleted file mode 100644 index 7ca8b4a..0000000 Binary files a/Semestr 4/rr1r/kol1/zad2.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/kol1/zad3.pdf b/Semestr 4/rr1r/kol1/zad3.pdf deleted file mode 100644 index 9fd9835..0000000 Binary files a/Semestr 4/rr1r/kol1/zad3.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista1/L1Z3.pdf b/Semestr 4/rr1r/lista1/L1Z3.pdf deleted file mode 100644 index 5646667..0000000 Binary files a/Semestr 4/rr1r/lista1/L1Z3.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista1/RR1R-01.pdf b/Semestr 4/rr1r/lista1/RR1R-01.pdf deleted file mode 100644 index 464de00..0000000 Binary files a/Semestr 4/rr1r/lista1/RR1R-01.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista2/L2Z4.pdf b/Semestr 4/rr1r/lista2/L2Z4.pdf deleted file mode 100644 index bfa182a..0000000 Binary files a/Semestr 4/rr1r/lista2/L2Z4.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista2/L2Z9.pdf b/Semestr 4/rr1r/lista2/L2Z9.pdf deleted file mode 100644 index 0f3675c..0000000 Binary files a/Semestr 4/rr1r/lista2/L2Z9.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista2/RR1R-02.pdf b/Semestr 4/rr1r/lista2/RR1R-02.pdf deleted file mode 100644 index 7d1a845..0000000 Binary files a/Semestr 4/rr1r/lista2/RR1R-02.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista3/RR1R-03.pdf b/Semestr 4/rr1r/lista3/RR1R-03.pdf deleted file mode 100644 index 22c3214..0000000 Binary files a/Semestr 4/rr1r/lista3/RR1R-03.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista4/RR1R-04.pdf b/Semestr 4/rr1r/lista4/RR1R-04.pdf deleted file mode 100644 index 4dfc8c3..0000000 Binary files a/Semestr 4/rr1r/lista4/RR1R-04.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista5/RR1R-05.pdf b/Semestr 4/rr1r/lista5/RR1R-05.pdf deleted file mode 100644 index 7dfa8d2..0000000 Binary files a/Semestr 4/rr1r/lista5/RR1R-05.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista6/RR1R-06.pdf b/Semestr 4/rr1r/lista6/RR1R-06.pdf deleted file mode 100644 index 596bb38..0000000 Binary files a/Semestr 4/rr1r/lista6/RR1R-06.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista7/RR1R-07.pdf b/Semestr 4/rr1r/lista7/RR1R-07.pdf deleted file mode 100644 index 7a6c6e1..0000000 Binary files a/Semestr 4/rr1r/lista7/RR1R-07.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista8/L8.pdf b/Semestr 4/rr1r/lista8/L8.pdf deleted file mode 100644 index 174c6f9..0000000 Binary files a/Semestr 4/rr1r/lista8/L8.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista8/RR1R-08.pdf b/Semestr 4/rr1r/lista8/RR1R-08.pdf deleted file mode 100644 index 4e39081..0000000 Binary files a/Semestr 4/rr1r/lista8/RR1R-08.pdf and /dev/null differ diff --git a/Semestr 4/rr1r/lista9/RR1R-09.pdf b/Semestr 4/rr1r/lista9/RR1R-09.pdf deleted file mode 100644 index 44191db..0000000 Binary files a/Semestr 4/rr1r/lista9/RR1R-09.pdf and /dev/null differ diff --git a/Semestr 4/sieci/cwiczenia1/c1.pdf b/Semestr 4/sieci/cwiczenia1/c1.pdf deleted file mode 100644 index ace2fa7..0000000 Binary files a/Semestr 4/sieci/cwiczenia1/c1.pdf and /dev/null differ diff --git a/Semestr 4/sieci/cwiczenia1/cw1.pdf b/Semestr 4/sieci/cwiczenia1/cw1.pdf deleted file mode 100644 index d217892..0000000 Binary files a/Semestr 4/sieci/cwiczenia1/cw1.pdf and /dev/null differ diff --git a/Semestr 4/sieci/cwiczenia1/out.pdf b/Semestr 4/sieci/cwiczenia1/out.pdf deleted file mode 100644 index ea7781d..0000000 Binary files a/Semestr 4/sieci/cwiczenia1/out.pdf and /dev/null differ diff --git a/Semestr 4/sieci/cwiczenia1/rozw.pdf b/Semestr 4/sieci/cwiczenia1/rozw.pdf deleted file mode 100644 index f2d1a62..0000000 Binary files a/Semestr 4/sieci/cwiczenia1/rozw.pdf and /dev/null differ diff --git a/Semestr 4/sieci/cwiczenia2/c2.pdf b/Semestr 4/sieci/cwiczenia2/c2.pdf deleted file mode 100644 index 3216f6f..0000000 Binary files a/Semestr 4/sieci/cwiczenia2/c2.pdf and /dev/null differ diff --git a/Semestr 4/sieci/pracownia1/makefile b/Semestr 4/sieci/pracownia1/makefile deleted file mode 100644 index 3c48d74..0000000 --- a/Semestr 4/sieci/pracownia1/makefile +++ /dev/null @@ -1,19 +0,0 @@ -CC=gcc -CFLAGS=-std=gnu17 -O2 -Wall -Wextra -TARGET=traceroute - -all: $(TARGET) - -$(TARGET): $(TARGET).o - $(CC) -o $(TARGET) $(TARGET).o - - -$(TARGET).o: $(TARGET).c - $(CC) $(CFLAGS) -c $(TARGET).c - -distclean: - $(RM) $(TARGET) - $(RM) $(TARGET).o - -clean: - $(RM) $(TARGET).o diff --git a/Semestr 4/sieci/pracownia1/p1.pdf b/Semestr 4/sieci/pracownia1/p1.pdf deleted file mode 100644 index 4b06555..0000000 Binary files a/Semestr 4/sieci/pracownia1/p1.pdf and /dev/null differ diff --git a/Semestr 4/sieci/pracownia1/traceroute.c b/Semestr 4/sieci/pracownia1/traceroute.c deleted file mode 100644 index 0e51c14..0000000 --- a/Semestr 4/sieci/pracownia1/traceroute.c +++ /dev/null @@ -1,240 +0,0 @@ -/* Pracownia programistyczna nr 1 - traceroute - * Imię i nazwisko: Franciszek Malinka - * Nr indeksu: 316093 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_TTL 30 -#define MESSAGES_PER_TTL 3 -#define NO_MESSAGES -1 -#define TOO_FEW_MESSAGES -2137 - -void print_as_bytes (unsigned char* buff, ssize_t length) -{ - for (ssize_t i = 0; i < length; i++, buff++) - printf ("%.2x ", *buff); -} - -void debug_received(uint8_t *buffer, struct sockaddr_in *sender, int packet_len) { - char ip_str[20]; - inet_ntop(AF_INET, &(sender->sin_addr), ip_str, sizeof(ip_str)); - - printf("IP packet with ICMP content from: %s\n", ip_str); - struct ip* ip_header = (struct ip*) buffer; - ssize_t ip_header_len = 4 * ip_header->ip_hl; - - printf ("IP header: "); - print_as_bytes (buffer, ip_header_len); - printf("\n"); - - printf ("IP data: "); - print_as_bytes (buffer + ip_header_len, packet_len - ip_header_len); - printf("\n\n"); -} - -struct sockaddr_in get_sockaddr_from_ip(char *ip) { - struct sockaddr_in sock; - bzero(&sock, sizeof(sock)); - sock.sin_family = AF_INET; - if (!inet_pton(AF_INET, ip, &sock.sin_addr)) { - fprintf(stderr, "Given ip is invalid: %s\n", ip); - exit(EXIT_FAILURE); - } - return sock; -} - -int create_raw_icmp_socket() { - int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); - if (sockfd < 0) { - fprintf(stderr, "socket error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - return sockfd; -} - -uint16_t compute_icmp_checksum(const void *buff, int length) -{ - uint32_t sum; - const uint16_t* ptr = buff; - assert (length % 2 == 0); - for (sum = 0; length > 0; length -= 2) - sum += *ptr++; - sum = (sum >> 16) + (sum & 0xffff); - return (uint16_t)(~(sum + (sum >> 16))); -} - -struct icmp create_icmp_header(uint16_t seq) { - struct icmp header; - header.icmp_type = ICMP_ECHO; - header.icmp_code = 0; - header.icmp_id = (uint16_t)getpid(); - header.icmp_seq = seq; - header.icmp_cksum = 0; - header.icmp_cksum = compute_icmp_checksum( - (uint16_t*)&header, sizeof(header)); - - return header; -} - -void send_icmp_packet(int sockfd, struct sockaddr_in *destination, int ttl) { - struct icmp header = create_icmp_header(ttl); - setsockopt(sockfd, IPPROTO_IP, IP_TTL, &ttl, sizeof(int)); - - ssize_t bytes_sent = sendto( - sockfd, - &header, - sizeof(header), - 0, - (struct sockaddr*)destination, - sizeof(*destination) - ); - if (bytes_sent == -1) { - fprintf(stderr, "Error while sending ICMP packet: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } -} - -/* Return ip address of the sender of recceived package */ -ssize_t recv_packet(int sockfd, struct sockaddr_in *sender, uint8_t *buffer) { - socklen_t sender_len = sizeof(*sender); - ssize_t packet_len = recvfrom(sockfd, buffer, IP_MAXPACKET, 0, - (struct sockaddr*)sender, &sender_len); - - if (packet_len == -1) { - fprintf(stderr, "Error while recieving a packet: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - return packet_len; -} - -void send_icmp_requests(int sockfd, struct sockaddr_in *destination, int ttl, int tries) { - for (int i = 0; i < tries; i++) { - send_icmp_packet(sockfd, destination, ttl); - } -} - -int try_select(int sockfd, struct timeval *tv) { - fd_set descriptors; - FD_ZERO(&descriptors); - FD_SET(sockfd, &descriptors); - return select(sockfd+1, &descriptors, NULL, NULL, tv); -} - -void pretty_print_router(int ttl, struct in_addr *senders, float mean_wait_time, int messages_received) { - char ip_str[20]; - printf("%d.\t", ttl); - if (messages_received == 0) { - printf("*\n"); - } - else { - for (int i = 0; i < messages_received; i++) { - bool already_printed = false; - for (int j = 0; j < i; j++) { - if (senders[i].s_addr == senders[j].s_addr) { - already_printed = true; - break; - } - } - if (already_printed) continue; - inet_ntop(AF_INET, senders + i, ip_str, sizeof(ip_str)); - printf("%-15s ", ip_str); - } - if (messages_received < MESSAGES_PER_TTL) printf("\t???\n"); - else printf("\t%.2fms\n", mean_wait_time); - } -} - -// This function decapsulates important data from the IMCP replies -void get_important_data(uint8_t *buffer, uint8_t *code, uint16_t *id, uint16_t *seq) { - struct ip* ip_header = (struct ip*) buffer; - ssize_t offset = 4 * ip_header->ip_hl; - *code = ((struct icmp *)(buffer + offset))->icmp_type; - if (*code != ICMP_ECHOREPLY && *code != ICMP_TIMXCEED) { - return; - } else if (*code == ICMP_TIMXCEED) { - offset += ICMP_MINLEN; - offset += 4 * ((struct ip *)(buffer + offset))->ip_hl; - *seq = ((struct icmp *)(buffer + offset))->icmp_seq; - *id = ((struct icmp *)(buffer + offset))->icmp_id; - } else { - *seq = ((struct icmp *)(buffer + offset))->icmp_seq; - *id = ((struct icmp *)(buffer + offset))->icmp_id; - } -} - -// timeout in milliseconds -float get_replies(int sockfd, long timeout, int ttl, int *messages_received, struct in_addr *senders) { - struct sockaddr_in sender; - uint8_t buffer[IP_MAXPACKET]; - int ready; - long mean_wait_time = 0; - struct timeval tv; tv.tv_sec = timeout / 1000; tv.tv_usec = 0; - *messages_received = 0; - - while ((ready = try_select(sockfd, &tv))) { - if (ready < 0) { - fprintf(stderr, "Select error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - recv_packet(sockfd, &sender, buffer); - uint8_t icmp_code = 0; - uint16_t seq = 0, id = 0; - - get_important_data(buffer, &icmp_code, &id, &seq); - if (seq == ttl) { - senders[(*messages_received)++] = sender.sin_addr; - mean_wait_time += timeout * 1000 - tv.tv_usec; - - if (*messages_received == MESSAGES_PER_TTL) break; - } - } - // changing from microseconds to miliseconds - return (float)mean_wait_time / 3.0 / 1000.0; -} - -// Core of the program. -void traceroute(struct sockaddr_in *destination) { - int sockfd = create_raw_icmp_socket(), messages_received = 0; - struct in_addr senders[MESSAGES_PER_TTL]; - - for (int ttl = 1; ttl <= MAX_TTL; ++ttl) { - send_icmp_requests(sockfd, destination, ttl, MESSAGES_PER_TTL); - float mean_wait_time = get_replies(sockfd, 1000, ttl, &messages_received, senders); - pretty_print_router(ttl, senders, mean_wait_time, messages_received); - - // what if our packet branched and we got to the destination faster by some path? - // we gotta make a loop, not an if - for (int i = 0; i < messages_received; i++) { - if (senders[i].s_addr == destination->sin_addr.s_addr) { - return; - } - } - } -} - -int main(int argc, char * argv[]) { - if (argc < 2) { - fprintf(stderr, "Usage:\n\t%s [host ip]\n", argv[0]); - return 1; - } - - struct sockaddr_in destination = get_sockaddr_from_ip(argv[1]); - fprintf(stdout, "traceroute to %s, %d hops max\n", argv[1], MAX_TTL); - traceroute(&destination); - - return 0; -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka.tar.xz b/Semestr 4/sieci/pracownia2/franciszek_malinka.tar.xz deleted file mode 100644 index ac3b1f7..0000000 Binary files a/Semestr 4/sieci/pracownia2/franciszek_malinka.tar.xz and /dev/null differ diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/config.h b/Semestr 4/sieci/pracownia2/franciszek_malinka/config.h deleted file mode 100644 index ee4eac0..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/config.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#define SERVER_PORT 54321 -#define TURN_LEN_S 20 - -#define INFINITY_DIST 16 -#define REACHABILITY_WAIT_TIME 3 - -#define DV_DATAGRAM_LEN 9 - -#define TURN_LEN_MS (1000 * TURN_LEN_S) -#define TURN_LEN_US (1000000 * TURN_LEN_S) - -#endif diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.c deleted file mode 100644 index 74ae82e..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "dist_vector.h" -#include -#include -#include - -bool is_connected_directly(struct vector_item item) { - return item.is_connected_directly; -} - -bool is_reachable(struct vector_item item) { - return (item.distance < INFINITY_DIST); -} - -void init_dv(list_t *dv, int n_cnt, struct network_addr *neighbours) { - for (int i = 0; i < n_cnt; i++) { - struct vector_item new_item; - new_item.network = neighbours[i]; - new_item.distance = INFINITY_DIST; - new_item.is_connected_directly = true; - insert(dv, &new_item, sizeof(new_item)); - } -} - -void update_dv_reachability(list_t *distance_vector) { - reset(distance_vector); - while (distance_vector->it != NULL) { - struct vector_item *current = (struct vector_item *)distance_vector->it->data; - if(++current->reachable > REACHABILITY_WAIT_TIME) { - if (current->distance >= INFINITY_DIST) { - if (!is_connected_directly(*current)) { - erase_it(distance_vector); - } - } else { - current->distance = INFINITY_DIST; - current->reachable = 0; - } - } - iterate(distance_vector); - } -} - -void update_dv_new_item(list_t *distance_vector, struct vector_item new_item) { - bool new_entry = true; - reset(distance_vector); - while (distance_vector->it != NULL) { - struct vector_item *current = (struct vector_item *)distance_vector->it->data; - - /* If the network is already in the distance vector, then we possibly want to change it: - * - if the new item has better distance than the previous one, then we just want to change it no matter what, - * - if the new item has the same via ip, then we want to check two things: - * - if new item has infinity dist, then we want to set infinity (if it wasn't set, then we want to change reachable to 0) - * - if new item has < inf dist, then we want to change reachable to 0 and set our dist accordingly. - * - else we ignore the entry. - */ - if (get_network_address(current->network).s_addr == get_network_address(new_item.network).s_addr) { - if (current->distance > new_item.distance) { - *current = new_item; - current->reachable = 0; - } else if(current->via_ip.s_addr == new_item.via_ip.s_addr) { - if (new_item.distance >= INFINITY_DIST) { - if (current->distance < INFINITY_DIST) { - current->distance = INFINITY_DIST; - current->reachable = 0; - } - } else { - current->distance = new_item.distance; - current->reachable = 0; - } - } - new_entry = false; - } - - iterate(distance_vector); - } - - if (new_entry && new_item.reachable < INFINITY_DIST) { - insert(distance_vector, &new_item, sizeof(new_item)); - } -} - -void print_dv(list_t *distance_vector) { - time_t rawtime; - struct tm * timeinfo; - - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - char t[100]; - strcpy(t, asctime(timeinfo)); - t[strlen(t) - 1] = 0; - printf("Distance vector [%s]:\n", t); - reset(distance_vector); - while (distance_vector->it != NULL) { - char addr[20], via_addr[20]; - struct vector_item current = *(struct vector_item *)distance_vector->it->data; - struct in_addr net_addr = get_network_address(current.network); - inet_ntop(AF_INET, &net_addr, addr, sizeof(addr)); - printf("%s/%d ", addr, current.network.netmask); - - if (is_reachable(current)) printf("distance %d ", current.distance); - else printf("unreachable "); - - inet_ntop(AF_INET, ¤t.via_ip, via_addr, sizeof(via_addr)); - if (is_connected_directly(current)) printf("connected directly\n"); - else printf("via %s\n", via_addr); - - iterate(distance_vector); - } - printf("\n"); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.h b/Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.h deleted file mode 100644 index 14159b4..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/dist_vector.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DIST_VECTOR_H -#define DIST_VECTOR_H - -#include "linked_list.h" -#include "network_addr.h" -#include "config.h" - -/* Item of the distance vector. - * If <> is set to 0, then it means that the network is reachable. - * If <> has positive value, then it indicates that the network was - * unreachable for <> turns. - */ -struct vector_item { - struct network_addr network; - struct in_addr via_ip; - uint16_t distance; - uint8_t reachable; - bool is_connected_directly; -}; - -/* Initis distance vector with given neighbours array. */ -void init_dv(list_t *dv, int n_cnt, struct network_addr *neighbours); - -/* Returns true if given distance vector item is connected directly, false otherwise. */ -bool is_connected_directly(struct vector_item item); - -/* Updates the distance vector. */ -void update_dv_new_item(list_t *distance_vector, struct vector_item new_item); - -/* Updates reachabilities. */ -void update_dv_reachability(list_t *distance_vector); - -/* Print distance vector. */ -void print_dv(list_t *distance_vector); - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c deleted file mode 100644 index 16113ac..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "linked_list.h" -#include -#include - -node_t *_next(node_t *node) { - return (node == NULL) ? NULL : node->next; -} - -void _insert(node_t **head, void *data, size_t data_size) { - node_t *new_node = (node_t *)malloc(sizeof(node_t)); - new_node->data = malloc(data_size); - for (int i = 0; i < data_size; i++) - *(uint8_t *)(new_node->data + i) = *(uint8_t *)(data + i); - new_node->next = *head; - *head = new_node; -} - -void _free_node(node_t *node) { - free(node->data); - free(node); -} - -void _erase(node_t **head) { - node_t *next_node = _next(*head); - _free_node(*head); - *head = next_node; -} - -void _free_list(node_t *head) { - if (head == NULL) return; - _free_list(head->next); - _free_node(head); -} - -list_t create_list() { - list_t ret; - ret.head = NULL; - ret.it = NULL; - return ret; -} - -void insert(list_t *list, void *data, size_t data_size) { - _insert(&list->head, data, data_size); -} - -void erase(list_t *list) { - _erase(&list->head); -} - -void erase_it(list_t *list) { - if(list->it == NULL) return; - if(list->prev_it == NULL) { - erase(list); - reset(list); - return; - } - list->prev_it->next = _next(list->it); - _free_node(list->it); - list->it = list->prev_it->next; -} - -void iterate(list_t *list) { - list->prev_it = list->it; - list->it = _next(list->it); -} - -void reset(list_t *list) { - list->prev_it = NULL; - list->it = list->head; -} - -void free_list(list_t *list) { - _free_list(list->head); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h b/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h deleted file mode 100644 index 1574b2f..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef LINKED_LIST_H -#define LINKED_LIST_H - -#include - -typedef struct node { - void *data; - struct node *next; -} node_t; - - -typedef struct list_t { - node_t *head; - node_t *it; - node_t *prev_it; -} list_t; - -/* Creates an empty list. */ -list_t create_list(); - -/* Insert a new node in the begining of a list. */ -void insert(list_t *list, void *data, size_t data_size); - -/* Erases first node from the list. */ -void erase(list_t *list); - -/* Erases element under iterator and sets iterator to the next one. */ -void erase_it(list_t *list); - -/* Moves iterator one step. */ -void iterate(list_t *list); - -/* Resets the iterator. - * Should execute the function after if you want to itarate unless you didnt insert or erase anything from the list. - */ -void reset(list_t *list); - -/* Deletes the whole list. */ -void free_list(list_t *list); - - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/makefile b/Semestr 4/sieci/pracownia2/franciszek_malinka/makefile deleted file mode 100644 index bf6a327..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/makefile +++ /dev/null @@ -1,34 +0,0 @@ -CC := gcc -CFLAGS := -O2 -std=gnu17 -Wall -Wall -Wno-unused-result -TARGET := router -TEST := test -DEPS := config.h - -ODIR := obj -_OBJ := router.o utils.o linked_list.o network_addr.o dist_vector.o -OBJ := $(patsubst %,$(ODIR)/%,$(_OBJ)) - -_TEST_OBJ := test.o linked_list.o -TEST_OBJ := $(patsubst %,$(ODIR)/%,$(_TEST_OBJ)) - - -all: $(TARGET) -test: $(TEST) - -$(ODIR)/%.o: %.c $(DEPS) - $(CC) $(CFLAGS) -c -o $@ $< - -$(TARGET): $(OBJ) - $(CC) -o $@ $^ $(CFLAGS) - -$(TEST): $(TEST_OBJ) - $(CC) -o $@ $^ $(CFLAGS) - -clean: - rm -rf $(TARGET) - rm -rf test - -distclean: - rm -rf $(TARGET) - rm -rf test - rm -rf $(ODIR)/*.o diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.c deleted file mode 100644 index cac1060..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "network_addr.h" -#include -#include -#include - -struct in_addr _get_broadcast_address(struct in_addr addr, uint16_t netmask) { - struct in_addr result = addr; - result.s_addr = ntohl(result.s_addr); - /* bitshift by more than 31 is UB */ - if (netmask == 0) { - result.s_addr = -1; - } - else { - result.s_addr |= ((1 << (32 - netmask)) - 1); - } - result.s_addr = htonl(result.s_addr); - - return result; -} - -struct in_addr _get_network_address(struct in_addr addr, uint16_t netmask) { - struct in_addr result = addr; - result.s_addr = ntohl(result.s_addr); - - if (netmask == 0) { - result.s_addr = 0; - } - else { - result.s_addr &= ~((1 << (32 - netmask)) - 1); - } - result.s_addr = htonl(result.s_addr); - - return result; -} - -struct in_addr get_broadcast_address(struct network_addr na) { - return _get_broadcast_address(na.addr, na.netmask); -} - -struct in_addr get_network_address(struct network_addr na) { - return _get_network_address(na.addr, na.netmask); -} - -void pretty_print_network(struct network_addr na) { - char ip_addr[20]; - inet_ntop(AF_INET, &na.addr, ip_addr, sizeof(ip_addr)); - printf("%s/%d\n", ip_addr, na.netmask); -} - -struct network_addr stona(char *str) { - struct network_addr result; - char addr[20]; - size_t ip_preffix = strcspn(str, "/"); - - strncpy(addr, str, ip_preffix); - addr[ip_preffix] = 0; - inet_pton(AF_INET, addr, &(result.addr)); - result.netmask = atoi(str + ip_preffix + 1); - return result; -} diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.h b/Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.h deleted file mode 100644 index 6347bbd..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/network_addr.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef ROUTER_ADDR_H -#define ROUTER_ADDR_H - -#include -#include -#include - -/* Network address with netmask. */ -struct network_addr { - struct in_addr addr; - uint8_t netmask; -}; - -typedef struct network_addr router_addr; - -/* Returns broadcast address of a given network. */ -struct in_addr get_broadcast_address(struct network_addr na); - -/* Returns network address of a given network. */ -struct in_addr get_network_address(struct network_addr na); - -/* Prints network_addr via stdio. */ -void pretty_print_network(struct network_addr na); - -/* Converts string of ip in CIDR notation with a netmask to network_addr. */ -struct network_addr stona(char *str); - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/router.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/router.c deleted file mode 100644 index b5e732c..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/router.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "network_addr.h" -#include "utils.h" -#include "dist_vector.h" - -uint16_t read_configuration(struct network_addr** networks, uint16_t **dists) { - uint16_t n; - scanf("%hd", &n); - *networks = malloc(n * sizeof(struct network_addr)); - *dists = malloc(n * sizeof(uint16_t)); - for (int i = 0; i < n; i++) { - char addr[20]; - char _dist[10]; - uint16_t dist; - scanf(" %s %s %hd", addr, _dist, &dist); - (*networks)[i] = stona(addr); - (*dists)[i] = dist; - } - return n; -} - -void router_loop(int sockfd, int networks_number, struct network_addr *networks, uint16_t *dists) { - list_t dv = create_list(); - init_dv(&dv, networks_number, networks); - - printf("Starting the router loop...\n"); - for (;;) { - print_dv(&dv); - propagate_distance_vector(sockfd, networks_number, networks, dists, &dv); - listen_for_routers(sockfd, TURN_LEN_MS, networks_number, networks, dists, &dv); - } -} - -int main() { - struct network_addr* networks; - uint16_t *dists; - int n = read_configuration(&networks, &dists); - int sockfd = get_socket(); - bind_to_port(sockfd, SERVER_PORT); - - router_loop(sockfd, n, networks, dists); - - close(sockfd); - free(networks); - free(dists); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/test.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/test.c deleted file mode 100644 index 958ff36..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/test.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "linked_list.h" -#include -#include - -/* Prints the list of ints to stdio */ -void print_list(list_t list) { - printf("List: "); - reset(&list); - while (list.it != NULL) { - printf("%d, ", *(int *)(list.it->data)); - iterate(&list); - } - printf("\n"); - reset(&list); -} - -int main() { - int n; - scanf("%d", &n); - list_t list = create_list(); - - for (int i = 0; i < n; i++) { - int t; - scanf("%d", &t); - // insert - if (t == 0) { - int val = 0; - scanf("%d", &val); - insert(&list, &val, sizeof(int)); - reset(&list); - } - if (t == 1) { - iterate(&list); - if (list.it != NULL) - printf("it: %d\n", *(int *)list.it->data); - else printf("End of list.\n"); - } - if (t == 2) { - erase_it(&list); - } - if (t == 3) { - print_list(list); - } - } - - free_list(&list); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/utils.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/utils.c deleted file mode 100644 index 0c0cae5..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/utils.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "utils.h" -#include -#include -#include -#include -#include -#include -#include - -int get_socket() { - int sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd < 0) { - fprintf(stderr, "Socket error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - return sockfd; -} - -void bind_to_port(int sockfd, uint16_t port) { - struct sockaddr_in server_address; - bzero(&server_address, sizeof(server_address)); - server_address.sin_family = AF_INET; - server_address.sin_port = htons(port); - server_address.sin_addr.s_addr = htonl(INADDR_ANY); - - if (bind(sockfd, (struct sockaddr*)&server_address, sizeof(server_address)) < 0) { - fprintf(stderr, "Bind error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - int broadcastPermission = 1; - setsockopt (sockfd, SOL_SOCKET, SO_BROADCAST, (void *)&broadcastPermission, sizeof(broadcastPermission)); -} - -long get_time_interval(struct timespec start, struct timespec finish) { - return S_TO_MS(finish.tv_sec - start.tv_sec) + NS_TO_MS(finish.tv_nsec - start.tv_nsec); -} - -int poll_socket_modify_timeout(int sockfd, int *timeout) { - if (*timeout < 0) { - *timeout = 0; - return 0; - } - - struct pollfd fds; - struct timespec start; - struct timespec finish; - - fds.fd = sockfd; - fds.events = POLLIN; - fds.revents = 0; - - clock_gettime(CLOCK_REALTIME, &start); - int result = poll(&fds, 1, *timeout); - clock_gettime(CLOCK_REALTIME, &finish); - - if (result == -1) { - fprintf(stderr, "poll error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - if (result == 0) { - *timeout = 0; - return 0; - } - - *timeout -= get_time_interval(start, finish); - return result; -} - -size_t send_message(int sockfd, char *buffer, int buffer_len, struct in_addr network) { - struct sockaddr_in network_address; - bzero (&network_address, sizeof(network_address)); - network_address.sin_family = AF_INET; - network_address.sin_port = htons(SERVER_PORT); - network_address.sin_addr = network; - - return sendto(sockfd, buffer, buffer_len, 0, (struct sockaddr*) &network_address, sizeof(network_address)); -} - -size_t recv_message(int sockfd, char *buffer, struct sockaddr_in *sender) { - socklen_t sender_len = sizeof(*sender); - for (int i = 0; i < DV_DATAGRAM_LEN; i++) buffer[i] = 0; - size_t datagram_len = recvfrom(sockfd, buffer, IP_MAXPACKET, 0, - (struct sockaddr*)sender, &sender_len); - if (datagram_len < 0) { - fprintf(stderr, "recvfrom error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - return datagram_len; -} - -struct vector_item parse_message(char *buffer, struct sockaddr_in *sender) { - struct vector_item res; - uint32_t ip_addr = *(uint32_t *)buffer; - uint32_t dist = *(uint32_t *)(buffer + 5); - dist = ntohl(dist); - - res.network.addr.s_addr = ip_addr; - res.network.netmask = buffer[4]; - res.is_connected_directly = true; - res.via_ip = sender->sin_addr; - res.distance = (dist < INFINITY_DIST ? dist : INFINITY_DIST); - res.reachable = 0; - - char addr[20]; - inet_ntop(AF_INET, &res.network.addr, addr, sizeof(addr)); - char via[20]; - inet_ntop(AF_INET, &sender->sin_addr, via, sizeof(via)); - return res; -} - -void _get_message(struct vector_item item, char *message) { - *(uint32_t *)message = item.network.addr.s_addr; - message[4] = item.network.netmask; - uint32_t distance = htonl(item.distance >= INFINITY_DIST ? INT_MAX : item.distance); - for (int i = 0; i < 4; i++) { - *(message + 5 + i) = *((char *)(&distance) + i); - } -} - -int _send_item(int sockfd, struct network_addr network, struct vector_item item) { - char message[DV_DATAGRAM_LEN + 1]; - _get_message(item, message); - message[DV_DATAGRAM_LEN] = 0; - ssize_t message_len = DV_DATAGRAM_LEN; - - struct in_addr na = get_broadcast_address(network); - - char addr[20]; - inet_ntop(AF_INET, &na, addr, sizeof(addr)); - - int result; - if ((result = send_message(sockfd, message, message_len, na)) != message_len) { - // fprintf(stderr, "sendto error: %s\n", strerror(errno)); - } - return result; -} - -void listen_for_routers(int sockfd, int timeout, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv) { - char buffer[IP_MAXPACKET + 1]; - struct sockaddr_in sender; - - while (poll_socket_modify_timeout(sockfd, &timeout)) { - recv_message(sockfd, buffer, &sender); - struct vector_item new_item = parse_message(buffer, &sender); - - bool is_neighbour = false; - for (int i = 0; i < networks_number; i++) { - if (is_from_network(sender.sin_addr, networks[i])) { - is_neighbour = true; - break; - } - } - - /* Shouldn't happen, just in case. */ - if (!is_neighbour) { - char addr[20]; - inet_ntop(AF_INET, &sender.sin_addr, addr, sizeof(addr)); - fprintf(stderr, "Received datagram from %s, he is in none of my networks, ignoring\n. Maybe his VM routing table is configured incorrectly?\n", addr); - continue; - } - - if (!is_from_network(sender.sin_addr, new_item.network)) { - new_item.is_connected_directly = false; - - for (int i = 0; i < networks_number; i++) { - if (is_from_network(sender.sin_addr, networks[i])) { - new_item.distance += dists[i]; - break; - } - } - } - - update_dv_new_item(dv, new_item); - } - update_dv_reachability(dv); -} - -void propagate_distance_vector(int sockfd, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv) { - for (int i = 0; i < networks_number; i++) { - reset(dv); - while (dv->it != NULL) { - struct vector_item data = *(struct vector_item *)dv->it->data; - if (!(get_network_address(data.network).s_addr == get_network_address(networks[i]).s_addr) && data.reachable <= REACHABILITY_WAIT_TIME) { - _send_item(sockfd, networks[i], data); - } - iterate(dv); - } - - struct vector_item self_item; - self_item.distance = dists[i]; - self_item.network = networks[i]; - _send_item(sockfd, networks[i], self_item); - } -} - -bool is_from_network(struct in_addr ip_addr, struct network_addr network) { - struct network_addr temp; - temp.addr= ip_addr; - temp.netmask = network.netmask; - return (get_network_address(temp).s_addr == get_network_address(network).s_addr); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/utils.h b/Semestr 4/sieci/pracownia2/franciszek_malinka/utils.h deleted file mode 100644 index edf90d0..0000000 --- a/Semestr 4/sieci/pracownia2/franciszek_malinka/utils.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H -#define UTILS_H - -#include "config.h" -#include -#include -#include -#include "network_addr.h" -#include "dist_vector.h" - -#define NS_TO_MS(X) ((long)(X) / (long)1000000) -#define S_TO_MS(X) ((long)(X) * (long)1000) - -/* Returns a UDP socket. */ -int get_socket(); - -/* Binds socket to given port and set the broadcast permission. */ -void bind_to_port(int sockfd, uint16_t port); - -/* Computes the time elapsed between start and finish in miliseconds. */ -long get_time_interval(struct timespec start, struct timespec finish); - -/* Polls given socket with given timeout and changes the timeout accordingly. */ -int poll_socket_modify_timeout(int sockfd, int *timeout); - -/* For debug purposes only. Recieves and prints UDP message. */ -void recv_and_print(int sockfd, int networks_number, struct network_addr *networks); - -/* Sends message in buffer of length buffer_len to addr through given socket. - * IT DOES NOT TERMINATE THE PROGRAM IF SENDTO RETURNS ANY ERRORS! - * One must handle the errors on their own. - */ -size_t send_message(int sockfd, char *buffer, int buffer_len, struct in_addr addr); - -/* Receive message and write it to buffer. */ -size_t recv_message(int sockfd, char *buffer, struct sockaddr_in *sender); - -/* Parse datagram into a vector item. */ -struct vector_item parse_message(char *buffer, struct sockaddr_in *sender); - -/* Listnes for routers for timeout ms. */ -void listen_for_routers(int sockfd, int timeout, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv); - -/* Propagates dv to all connected networks. */ -void propagate_distance_vector(int sockfd, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv); - -/* Checks if given address is in network range. */ -bool is_from_network(struct in_addr ip_addr, struct network_addr network); - - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/p2.pdf b/Semestr 4/sieci/pracownia2/p2.pdf deleted file mode 100644 index f0cc942..0000000 Binary files a/Semestr 4/sieci/pracownia2/p2.pdf and /dev/null differ diff --git a/Semestr 4/sieci/pracownia2/router/config.h b/Semestr 4/sieci/pracownia2/router/config.h deleted file mode 100644 index f83c556..0000000 --- a/Semestr 4/sieci/pracownia2/router/config.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#define SERVER_PORT 54321 -#define TURN_LEN_S 5 - -#define INFINITY_DIST 16 -#define REACHABILITY_WAIT_TIME 3 - -#define DV_DATAGRAM_LEN 9 - -#define TURN_LEN_MS (1000 * TURN_LEN_S) -#define TURN_LEN_US (1000000 * TURN_LEN_S) - -#endif diff --git a/Semestr 4/sieci/pracownia2/router/dist_vector.c b/Semestr 4/sieci/pracownia2/router/dist_vector.c deleted file mode 100644 index 74ae82e..0000000 --- a/Semestr 4/sieci/pracownia2/router/dist_vector.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "dist_vector.h" -#include -#include -#include - -bool is_connected_directly(struct vector_item item) { - return item.is_connected_directly; -} - -bool is_reachable(struct vector_item item) { - return (item.distance < INFINITY_DIST); -} - -void init_dv(list_t *dv, int n_cnt, struct network_addr *neighbours) { - for (int i = 0; i < n_cnt; i++) { - struct vector_item new_item; - new_item.network = neighbours[i]; - new_item.distance = INFINITY_DIST; - new_item.is_connected_directly = true; - insert(dv, &new_item, sizeof(new_item)); - } -} - -void update_dv_reachability(list_t *distance_vector) { - reset(distance_vector); - while (distance_vector->it != NULL) { - struct vector_item *current = (struct vector_item *)distance_vector->it->data; - if(++current->reachable > REACHABILITY_WAIT_TIME) { - if (current->distance >= INFINITY_DIST) { - if (!is_connected_directly(*current)) { - erase_it(distance_vector); - } - } else { - current->distance = INFINITY_DIST; - current->reachable = 0; - } - } - iterate(distance_vector); - } -} - -void update_dv_new_item(list_t *distance_vector, struct vector_item new_item) { - bool new_entry = true; - reset(distance_vector); - while (distance_vector->it != NULL) { - struct vector_item *current = (struct vector_item *)distance_vector->it->data; - - /* If the network is already in the distance vector, then we possibly want to change it: - * - if the new item has better distance than the previous one, then we just want to change it no matter what, - * - if the new item has the same via ip, then we want to check two things: - * - if new item has infinity dist, then we want to set infinity (if it wasn't set, then we want to change reachable to 0) - * - if new item has < inf dist, then we want to change reachable to 0 and set our dist accordingly. - * - else we ignore the entry. - */ - if (get_network_address(current->network).s_addr == get_network_address(new_item.network).s_addr) { - if (current->distance > new_item.distance) { - *current = new_item; - current->reachable = 0; - } else if(current->via_ip.s_addr == new_item.via_ip.s_addr) { - if (new_item.distance >= INFINITY_DIST) { - if (current->distance < INFINITY_DIST) { - current->distance = INFINITY_DIST; - current->reachable = 0; - } - } else { - current->distance = new_item.distance; - current->reachable = 0; - } - } - new_entry = false; - } - - iterate(distance_vector); - } - - if (new_entry && new_item.reachable < INFINITY_DIST) { - insert(distance_vector, &new_item, sizeof(new_item)); - } -} - -void print_dv(list_t *distance_vector) { - time_t rawtime; - struct tm * timeinfo; - - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - char t[100]; - strcpy(t, asctime(timeinfo)); - t[strlen(t) - 1] = 0; - printf("Distance vector [%s]:\n", t); - reset(distance_vector); - while (distance_vector->it != NULL) { - char addr[20], via_addr[20]; - struct vector_item current = *(struct vector_item *)distance_vector->it->data; - struct in_addr net_addr = get_network_address(current.network); - inet_ntop(AF_INET, &net_addr, addr, sizeof(addr)); - printf("%s/%d ", addr, current.network.netmask); - - if (is_reachable(current)) printf("distance %d ", current.distance); - else printf("unreachable "); - - inet_ntop(AF_INET, ¤t.via_ip, via_addr, sizeof(via_addr)); - if (is_connected_directly(current)) printf("connected directly\n"); - else printf("via %s\n", via_addr); - - iterate(distance_vector); - } - printf("\n"); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/dist_vector.h b/Semestr 4/sieci/pracownia2/router/dist_vector.h deleted file mode 100644 index 14159b4..0000000 --- a/Semestr 4/sieci/pracownia2/router/dist_vector.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DIST_VECTOR_H -#define DIST_VECTOR_H - -#include "linked_list.h" -#include "network_addr.h" -#include "config.h" - -/* Item of the distance vector. - * If <> is set to 0, then it means that the network is reachable. - * If <> has positive value, then it indicates that the network was - * unreachable for <> turns. - */ -struct vector_item { - struct network_addr network; - struct in_addr via_ip; - uint16_t distance; - uint8_t reachable; - bool is_connected_directly; -}; - -/* Initis distance vector with given neighbours array. */ -void init_dv(list_t *dv, int n_cnt, struct network_addr *neighbours); - -/* Returns true if given distance vector item is connected directly, false otherwise. */ -bool is_connected_directly(struct vector_item item); - -/* Updates the distance vector. */ -void update_dv_new_item(list_t *distance_vector, struct vector_item new_item); - -/* Updates reachabilities. */ -void update_dv_reachability(list_t *distance_vector); - -/* Print distance vector. */ -void print_dv(list_t *distance_vector); - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/linked_list.c b/Semestr 4/sieci/pracownia2/router/linked_list.c deleted file mode 100644 index 16113ac..0000000 --- a/Semestr 4/sieci/pracownia2/router/linked_list.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "linked_list.h" -#include -#include - -node_t *_next(node_t *node) { - return (node == NULL) ? NULL : node->next; -} - -void _insert(node_t **head, void *data, size_t data_size) { - node_t *new_node = (node_t *)malloc(sizeof(node_t)); - new_node->data = malloc(data_size); - for (int i = 0; i < data_size; i++) - *(uint8_t *)(new_node->data + i) = *(uint8_t *)(data + i); - new_node->next = *head; - *head = new_node; -} - -void _free_node(node_t *node) { - free(node->data); - free(node); -} - -void _erase(node_t **head) { - node_t *next_node = _next(*head); - _free_node(*head); - *head = next_node; -} - -void _free_list(node_t *head) { - if (head == NULL) return; - _free_list(head->next); - _free_node(head); -} - -list_t create_list() { - list_t ret; - ret.head = NULL; - ret.it = NULL; - return ret; -} - -void insert(list_t *list, void *data, size_t data_size) { - _insert(&list->head, data, data_size); -} - -void erase(list_t *list) { - _erase(&list->head); -} - -void erase_it(list_t *list) { - if(list->it == NULL) return; - if(list->prev_it == NULL) { - erase(list); - reset(list); - return; - } - list->prev_it->next = _next(list->it); - _free_node(list->it); - list->it = list->prev_it->next; -} - -void iterate(list_t *list) { - list->prev_it = list->it; - list->it = _next(list->it); -} - -void reset(list_t *list) { - list->prev_it = NULL; - list->it = list->head; -} - -void free_list(list_t *list) { - _free_list(list->head); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/linked_list.h b/Semestr 4/sieci/pracownia2/router/linked_list.h deleted file mode 100644 index 1574b2f..0000000 --- a/Semestr 4/sieci/pracownia2/router/linked_list.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef LINKED_LIST_H -#define LINKED_LIST_H - -#include - -typedef struct node { - void *data; - struct node *next; -} node_t; - - -typedef struct list_t { - node_t *head; - node_t *it; - node_t *prev_it; -} list_t; - -/* Creates an empty list. */ -list_t create_list(); - -/* Insert a new node in the begining of a list. */ -void insert(list_t *list, void *data, size_t data_size); - -/* Erases first node from the list. */ -void erase(list_t *list); - -/* Erases element under iterator and sets iterator to the next one. */ -void erase_it(list_t *list); - -/* Moves iterator one step. */ -void iterate(list_t *list); - -/* Resets the iterator. - * Should execute the function after if you want to itarate unless you didnt insert or erase anything from the list. - */ -void reset(list_t *list); - -/* Deletes the whole list. */ -void free_list(list_t *list); - - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/makefile b/Semestr 4/sieci/pracownia2/router/makefile deleted file mode 100644 index bf6a327..0000000 --- a/Semestr 4/sieci/pracownia2/router/makefile +++ /dev/null @@ -1,34 +0,0 @@ -CC := gcc -CFLAGS := -O2 -std=gnu17 -Wall -Wall -Wno-unused-result -TARGET := router -TEST := test -DEPS := config.h - -ODIR := obj -_OBJ := router.o utils.o linked_list.o network_addr.o dist_vector.o -OBJ := $(patsubst %,$(ODIR)/%,$(_OBJ)) - -_TEST_OBJ := test.o linked_list.o -TEST_OBJ := $(patsubst %,$(ODIR)/%,$(_TEST_OBJ)) - - -all: $(TARGET) -test: $(TEST) - -$(ODIR)/%.o: %.c $(DEPS) - $(CC) $(CFLAGS) -c -o $@ $< - -$(TARGET): $(OBJ) - $(CC) -o $@ $^ $(CFLAGS) - -$(TEST): $(TEST_OBJ) - $(CC) -o $@ $^ $(CFLAGS) - -clean: - rm -rf $(TARGET) - rm -rf test - -distclean: - rm -rf $(TARGET) - rm -rf test - rm -rf $(ODIR)/*.o diff --git a/Semestr 4/sieci/pracownia2/router/network_addr.c b/Semestr 4/sieci/pracownia2/router/network_addr.c deleted file mode 100644 index cac1060..0000000 --- a/Semestr 4/sieci/pracownia2/router/network_addr.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "network_addr.h" -#include -#include -#include - -struct in_addr _get_broadcast_address(struct in_addr addr, uint16_t netmask) { - struct in_addr result = addr; - result.s_addr = ntohl(result.s_addr); - /* bitshift by more than 31 is UB */ - if (netmask == 0) { - result.s_addr = -1; - } - else { - result.s_addr |= ((1 << (32 - netmask)) - 1); - } - result.s_addr = htonl(result.s_addr); - - return result; -} - -struct in_addr _get_network_address(struct in_addr addr, uint16_t netmask) { - struct in_addr result = addr; - result.s_addr = ntohl(result.s_addr); - - if (netmask == 0) { - result.s_addr = 0; - } - else { - result.s_addr &= ~((1 << (32 - netmask)) - 1); - } - result.s_addr = htonl(result.s_addr); - - return result; -} - -struct in_addr get_broadcast_address(struct network_addr na) { - return _get_broadcast_address(na.addr, na.netmask); -} - -struct in_addr get_network_address(struct network_addr na) { - return _get_network_address(na.addr, na.netmask); -} - -void pretty_print_network(struct network_addr na) { - char ip_addr[20]; - inet_ntop(AF_INET, &na.addr, ip_addr, sizeof(ip_addr)); - printf("%s/%d\n", ip_addr, na.netmask); -} - -struct network_addr stona(char *str) { - struct network_addr result; - char addr[20]; - size_t ip_preffix = strcspn(str, "/"); - - strncpy(addr, str, ip_preffix); - addr[ip_preffix] = 0; - inet_pton(AF_INET, addr, &(result.addr)); - result.netmask = atoi(str + ip_preffix + 1); - return result; -} diff --git a/Semestr 4/sieci/pracownia2/router/network_addr.h b/Semestr 4/sieci/pracownia2/router/network_addr.h deleted file mode 100644 index 6347bbd..0000000 --- a/Semestr 4/sieci/pracownia2/router/network_addr.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef ROUTER_ADDR_H -#define ROUTER_ADDR_H - -#include -#include -#include - -/* Network address with netmask. */ -struct network_addr { - struct in_addr addr; - uint8_t netmask; -}; - -typedef struct network_addr router_addr; - -/* Returns broadcast address of a given network. */ -struct in_addr get_broadcast_address(struct network_addr na); - -/* Returns network address of a given network. */ -struct in_addr get_network_address(struct network_addr na); - -/* Prints network_addr via stdio. */ -void pretty_print_network(struct network_addr na); - -/* Converts string of ip in CIDR notation with a netmask to network_addr. */ -struct network_addr stona(char *str); - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/router.c b/Semestr 4/sieci/pracownia2/router/router.c deleted file mode 100644 index b5e732c..0000000 --- a/Semestr 4/sieci/pracownia2/router/router.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "network_addr.h" -#include "utils.h" -#include "dist_vector.h" - -uint16_t read_configuration(struct network_addr** networks, uint16_t **dists) { - uint16_t n; - scanf("%hd", &n); - *networks = malloc(n * sizeof(struct network_addr)); - *dists = malloc(n * sizeof(uint16_t)); - for (int i = 0; i < n; i++) { - char addr[20]; - char _dist[10]; - uint16_t dist; - scanf(" %s %s %hd", addr, _dist, &dist); - (*networks)[i] = stona(addr); - (*dists)[i] = dist; - } - return n; -} - -void router_loop(int sockfd, int networks_number, struct network_addr *networks, uint16_t *dists) { - list_t dv = create_list(); - init_dv(&dv, networks_number, networks); - - printf("Starting the router loop...\n"); - for (;;) { - print_dv(&dv); - propagate_distance_vector(sockfd, networks_number, networks, dists, &dv); - listen_for_routers(sockfd, TURN_LEN_MS, networks_number, networks, dists, &dv); - } -} - -int main() { - struct network_addr* networks; - uint16_t *dists; - int n = read_configuration(&networks, &dists); - int sockfd = get_socket(); - bind_to_port(sockfd, SERVER_PORT); - - router_loop(sockfd, n, networks, dists); - - close(sockfd); - free(networks); - free(dists); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/test.c b/Semestr 4/sieci/pracownia2/router/test.c deleted file mode 100644 index 958ff36..0000000 --- a/Semestr 4/sieci/pracownia2/router/test.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "linked_list.h" -#include -#include - -/* Prints the list of ints to stdio */ -void print_list(list_t list) { - printf("List: "); - reset(&list); - while (list.it != NULL) { - printf("%d, ", *(int *)(list.it->data)); - iterate(&list); - } - printf("\n"); - reset(&list); -} - -int main() { - int n; - scanf("%d", &n); - list_t list = create_list(); - - for (int i = 0; i < n; i++) { - int t; - scanf("%d", &t); - // insert - if (t == 0) { - int val = 0; - scanf("%d", &val); - insert(&list, &val, sizeof(int)); - reset(&list); - } - if (t == 1) { - iterate(&list); - if (list.it != NULL) - printf("it: %d\n", *(int *)list.it->data); - else printf("End of list.\n"); - } - if (t == 2) { - erase_it(&list); - } - if (t == 3) { - print_list(list); - } - } - - free_list(&list); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/utils.c b/Semestr 4/sieci/pracownia2/router/utils.c deleted file mode 100644 index 0c0cae5..0000000 --- a/Semestr 4/sieci/pracownia2/router/utils.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Program: router - * Autor: Franciszek Malinka, 316093 - */ - -#include "utils.h" -#include -#include -#include -#include -#include -#include -#include - -int get_socket() { - int sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd < 0) { - fprintf(stderr, "Socket error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - return sockfd; -} - -void bind_to_port(int sockfd, uint16_t port) { - struct sockaddr_in server_address; - bzero(&server_address, sizeof(server_address)); - server_address.sin_family = AF_INET; - server_address.sin_port = htons(port); - server_address.sin_addr.s_addr = htonl(INADDR_ANY); - - if (bind(sockfd, (struct sockaddr*)&server_address, sizeof(server_address)) < 0) { - fprintf(stderr, "Bind error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - int broadcastPermission = 1; - setsockopt (sockfd, SOL_SOCKET, SO_BROADCAST, (void *)&broadcastPermission, sizeof(broadcastPermission)); -} - -long get_time_interval(struct timespec start, struct timespec finish) { - return S_TO_MS(finish.tv_sec - start.tv_sec) + NS_TO_MS(finish.tv_nsec - start.tv_nsec); -} - -int poll_socket_modify_timeout(int sockfd, int *timeout) { - if (*timeout < 0) { - *timeout = 0; - return 0; - } - - struct pollfd fds; - struct timespec start; - struct timespec finish; - - fds.fd = sockfd; - fds.events = POLLIN; - fds.revents = 0; - - clock_gettime(CLOCK_REALTIME, &start); - int result = poll(&fds, 1, *timeout); - clock_gettime(CLOCK_REALTIME, &finish); - - if (result == -1) { - fprintf(stderr, "poll error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - if (result == 0) { - *timeout = 0; - return 0; - } - - *timeout -= get_time_interval(start, finish); - return result; -} - -size_t send_message(int sockfd, char *buffer, int buffer_len, struct in_addr network) { - struct sockaddr_in network_address; - bzero (&network_address, sizeof(network_address)); - network_address.sin_family = AF_INET; - network_address.sin_port = htons(SERVER_PORT); - network_address.sin_addr = network; - - return sendto(sockfd, buffer, buffer_len, 0, (struct sockaddr*) &network_address, sizeof(network_address)); -} - -size_t recv_message(int sockfd, char *buffer, struct sockaddr_in *sender) { - socklen_t sender_len = sizeof(*sender); - for (int i = 0; i < DV_DATAGRAM_LEN; i++) buffer[i] = 0; - size_t datagram_len = recvfrom(sockfd, buffer, IP_MAXPACKET, 0, - (struct sockaddr*)sender, &sender_len); - if (datagram_len < 0) { - fprintf(stderr, "recvfrom error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - return datagram_len; -} - -struct vector_item parse_message(char *buffer, struct sockaddr_in *sender) { - struct vector_item res; - uint32_t ip_addr = *(uint32_t *)buffer; - uint32_t dist = *(uint32_t *)(buffer + 5); - dist = ntohl(dist); - - res.network.addr.s_addr = ip_addr; - res.network.netmask = buffer[4]; - res.is_connected_directly = true; - res.via_ip = sender->sin_addr; - res.distance = (dist < INFINITY_DIST ? dist : INFINITY_DIST); - res.reachable = 0; - - char addr[20]; - inet_ntop(AF_INET, &res.network.addr, addr, sizeof(addr)); - char via[20]; - inet_ntop(AF_INET, &sender->sin_addr, via, sizeof(via)); - return res; -} - -void _get_message(struct vector_item item, char *message) { - *(uint32_t *)message = item.network.addr.s_addr; - message[4] = item.network.netmask; - uint32_t distance = htonl(item.distance >= INFINITY_DIST ? INT_MAX : item.distance); - for (int i = 0; i < 4; i++) { - *(message + 5 + i) = *((char *)(&distance) + i); - } -} - -int _send_item(int sockfd, struct network_addr network, struct vector_item item) { - char message[DV_DATAGRAM_LEN + 1]; - _get_message(item, message); - message[DV_DATAGRAM_LEN] = 0; - ssize_t message_len = DV_DATAGRAM_LEN; - - struct in_addr na = get_broadcast_address(network); - - char addr[20]; - inet_ntop(AF_INET, &na, addr, sizeof(addr)); - - int result; - if ((result = send_message(sockfd, message, message_len, na)) != message_len) { - // fprintf(stderr, "sendto error: %s\n", strerror(errno)); - } - return result; -} - -void listen_for_routers(int sockfd, int timeout, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv) { - char buffer[IP_MAXPACKET + 1]; - struct sockaddr_in sender; - - while (poll_socket_modify_timeout(sockfd, &timeout)) { - recv_message(sockfd, buffer, &sender); - struct vector_item new_item = parse_message(buffer, &sender); - - bool is_neighbour = false; - for (int i = 0; i < networks_number; i++) { - if (is_from_network(sender.sin_addr, networks[i])) { - is_neighbour = true; - break; - } - } - - /* Shouldn't happen, just in case. */ - if (!is_neighbour) { - char addr[20]; - inet_ntop(AF_INET, &sender.sin_addr, addr, sizeof(addr)); - fprintf(stderr, "Received datagram from %s, he is in none of my networks, ignoring\n. Maybe his VM routing table is configured incorrectly?\n", addr); - continue; - } - - if (!is_from_network(sender.sin_addr, new_item.network)) { - new_item.is_connected_directly = false; - - for (int i = 0; i < networks_number; i++) { - if (is_from_network(sender.sin_addr, networks[i])) { - new_item.distance += dists[i]; - break; - } - } - } - - update_dv_new_item(dv, new_item); - } - update_dv_reachability(dv); -} - -void propagate_distance_vector(int sockfd, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv) { - for (int i = 0; i < networks_number; i++) { - reset(dv); - while (dv->it != NULL) { - struct vector_item data = *(struct vector_item *)dv->it->data; - if (!(get_network_address(data.network).s_addr == get_network_address(networks[i]).s_addr) && data.reachable <= REACHABILITY_WAIT_TIME) { - _send_item(sockfd, networks[i], data); - } - iterate(dv); - } - - struct vector_item self_item; - self_item.distance = dists[i]; - self_item.network = networks[i]; - _send_item(sockfd, networks[i], self_item); - } -} - -bool is_from_network(struct in_addr ip_addr, struct network_addr network) { - struct network_addr temp; - temp.addr= ip_addr; - temp.netmask = network.netmask; - return (get_network_address(temp).s_addr == get_network_address(network).s_addr); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/router/utils.h b/Semestr 4/sieci/pracownia2/router/utils.h deleted file mode 100644 index edf90d0..0000000 --- a/Semestr 4/sieci/pracownia2/router/utils.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H -#define UTILS_H - -#include "config.h" -#include -#include -#include -#include "network_addr.h" -#include "dist_vector.h" - -#define NS_TO_MS(X) ((long)(X) / (long)1000000) -#define S_TO_MS(X) ((long)(X) * (long)1000) - -/* Returns a UDP socket. */ -int get_socket(); - -/* Binds socket to given port and set the broadcast permission. */ -void bind_to_port(int sockfd, uint16_t port); - -/* Computes the time elapsed between start and finish in miliseconds. */ -long get_time_interval(struct timespec start, struct timespec finish); - -/* Polls given socket with given timeout and changes the timeout accordingly. */ -int poll_socket_modify_timeout(int sockfd, int *timeout); - -/* For debug purposes only. Recieves and prints UDP message. */ -void recv_and_print(int sockfd, int networks_number, struct network_addr *networks); - -/* Sends message in buffer of length buffer_len to addr through given socket. - * IT DOES NOT TERMINATE THE PROGRAM IF SENDTO RETURNS ANY ERRORS! - * One must handle the errors on their own. - */ -size_t send_message(int sockfd, char *buffer, int buffer_len, struct in_addr addr); - -/* Receive message and write it to buffer. */ -size_t recv_message(int sockfd, char *buffer, struct sockaddr_in *sender); - -/* Parse datagram into a vector item. */ -struct vector_item parse_message(char *buffer, struct sockaddr_in *sender); - -/* Listnes for routers for timeout ms. */ -void listen_for_routers(int sockfd, int timeout, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv); - -/* Propagates dv to all connected networks. */ -void propagate_distance_vector(int sockfd, int networks_number, struct network_addr *networks, uint16_t *dists, list_t *dv); - -/* Checks if given address is in network range. */ -bool is_from_network(struct in_addr ip_addr, struct network_addr network); - - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia2/udp_client.c b/Semestr 4/sieci/pracownia2/udp_client.c deleted file mode 100755 index 4e7dce4..0000000 --- a/Semestr 4/sieci/pracownia2/udp_client.c +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char * argv[]) -{ - if (argc < 2) { - printf("Usage:\n\t%s [server ip]\n", argv[0]); - return -1; - } - - int sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd < 0) { - fprintf(stderr, "socket error: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - struct sockaddr_in server_address; - bzero (&server_address, sizeof(server_address)); - server_address.sin_family = AF_INET; - server_address.sin_port = htons(54321); - if (!inet_pton(AF_INET, argv[1], &server_address.sin_addr)) { - printf("Inavlid ip address\n"); - return -1; - } - - char* message = "Hello server!"; - ssize_t message_len = strlen(message); - if (sendto(sockfd, message, message_len, 0, (struct sockaddr*) &server_address, sizeof(server_address)) != message_len) { - fprintf(stderr, "sendto error: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - close (sockfd); - return EXIT_SUCCESS; -} - diff --git a/Semestr 4/sieci/pracownia2/udp_server.c b/Semestr 4/sieci/pracownia2/udp_server.c deleted file mode 100755 index b5ae6d1..0000000 --- a/Semestr 4/sieci/pracownia2/udp_server.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -int main() -{ - int sockfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sockfd < 0) { - fprintf(stderr, "socket error: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - struct sockaddr_in server_address; - bzero (&server_address, sizeof(server_address)); - server_address.sin_family = AF_INET; - server_address.sin_port = htons(54321); - server_address.sin_addr.s_addr = htonl(INADDR_ANY); - if (bind (sockfd, (struct sockaddr*)&server_address, sizeof(server_address)) < 0) { - fprintf(stderr, "bind error: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - for (;;) { - - struct sockaddr_in sender; - socklen_t sender_len = sizeof(sender); - u_int8_t buffer[IP_MAXPACKET+1]; - - ssize_t datagram_len = recvfrom (sockfd, buffer, IP_MAXPACKET, 0, (struct sockaddr*)&sender, &sender_len); - if (datagram_len < 0) { - fprintf(stderr, "recvfrom error: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - char sender_ip_str[20]; - inet_ntop(AF_INET, &(sender.sin_addr), sender_ip_str, sizeof(sender_ip_str)); - printf ("Received UDP packet from IP address: %s, port: %d\n", sender_ip_str, ntohs(sender.sin_port)); - - buffer[datagram_len] = 0; - printf ("%ld-byte message: +%s+\n", datagram_len, buffer); - - char* reply = "Thank you!"; - ssize_t reply_len = strlen(reply); - if (sendto(sockfd, reply, reply_len, 0, (struct sockaddr*)&sender, sender_len) != reply_len) { - fprintf(stderr, "sendto error: %s\n", strerror(errno)); - return EXIT_FAILURE; - } - - fflush(stdout); - } - - close (sockfd); - return EXIT_SUCCESS; -} - diff --git a/Semestr 4/sieci/pracownia3/config.h b/Semestr 4/sieci/pracownia3/config.h deleted file mode 100644 index 3b81646..0000000 --- a/Semestr 4/sieci/pracownia3/config.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#define DATAGRAM_LEN 1000 -#define HEADER_LEN 40 - -#define WINDOW_SIZE 3000 -#define TIMEOUT 100 - -#endif diff --git a/Semestr 4/sieci/pracownia3/p3.pdf b/Semestr 4/sieci/pracownia3/p3.pdf deleted file mode 100644 index 14f1261..0000000 Binary files a/Semestr 4/sieci/pracownia3/p3.pdf and /dev/null differ diff --git a/Semestr 4/sieci/pracownia3/transport.c b/Semestr 4/sieci/pracownia3/transport.c deleted file mode 100644 index 9226d69..0000000 --- a/Semestr 4/sieci/pracownia3/transport.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Projekt: Transport - * Autor: Franciszek Malinka 316093 - */ - -#include -#include -#include -#include -#include -#include -#include -#include "config.h" -#include "window.h" -#include "utils.h" - -size_t send_datagram(int sockfd, struct sockaddr_in server_address, char *buffer, size_t buffer_len) { - return sendto(sockfd, buffer, buffer_len, 0, (struct sockaddr*) &server_address, sizeof(server_address)); -} - -void send_data_request(int sockfd, struct sockaddr_in server_address, size_t pos, size_t bytes) { - char buffer[40]; - sprintf(buffer, "GET %ld %ld\n", pos, bytes); - size_t buffer_len = strlen(buffer); - if (send_datagram(sockfd, server_address, buffer, buffer_len) != buffer_len) { - fprintf(stderr, "sendto error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } -} - -size_t recv_message(int sockfd, char *buffer, struct sockaddr_in *sender) { - socklen_t sender_len = sizeof(*sender); - bzero(buffer, HEADER_LEN + DATAGRAM_LEN); - bzero(sender, sizeof(*sender)); - size_t datagram_len = recvfrom(sockfd, buffer, IP_MAXPACKET, 0, - (struct sockaddr*)sender, &sender_len); - - if (datagram_len < 0) { - fprintf(stderr, "recvfrom error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - - return datagram_len; -} - -void request_data(int sockfd, struct sockaddr_in server_address, window_t *w, size_t bytes_writen, size_t remaining_bytes) { - int pos = w->first_pos; - for (int i = 0; i < w->size && i*DATAGRAM_LEN < remaining_bytes; i++) { - if (w->uptodate[pos] == false) { - size_t bytes_to_request = min(DATAGRAM_LEN, remaining_bytes - i*DATAGRAM_LEN); - send_data_request(sockfd, server_address, bytes_writen + i*DATAGRAM_LEN, bytes_to_request); - } - pos = (pos + 1) % w->size; - } -} - -void update_file(FILE *fd, window_t *w, size_t *bytes_writen, size_t *remaining_bytes) { - while (w->uptodate[w->first_pos] && *remaining_bytes > 0) { - // printf("Writing %ld\n", *bytes_writen); - size_t bytes_to_write = min(DATAGRAM_LEN, *remaining_bytes); - fwrite(w->ar[w->first_pos], sizeof(char), bytes_to_write, fd); - *bytes_writen += bytes_to_write; - *remaining_bytes -= bytes_to_write; - shift(w); - } -} - -size_t recv_datagram(int sockfd, char *buffer, struct sockaddr_in server_address) { - struct sockaddr_in sender; - - size_t received_bytes = recv_message(sockfd, buffer, &sender); - if (sender.sin_addr.s_addr != server_address.sin_addr.s_addr || sender.sin_port != server_address.sin_port) { - printf("Smieci!\n"); - return 0; - } - return received_bytes; -} - - -void receive_file(int sockfd, struct sockaddr_in server_address, const char *file_name, size_t remaining_bytes) { - FILE *fd = fopen(file_name, "w"); - if (!fd) { - fprintf(stderr, "fopen error: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - size_t bytes_writen = 0; - - size_t recv_pos, recv_len; - char buffer[DATAGRAM_LEN + HEADER_LEN]; - int prev_len = 0; - window_t w; - init_window(&w, WINDOW_SIZE, DATAGRAM_LEN); - - while (remaining_bytes) { - request_data(sockfd, server_address, &w, bytes_writen, remaining_bytes); - int timeout = TIMEOUT; - while (poll_socket_modify_timeout(sockfd, &timeout)) { - size_t received_bytes = recv_datagram(sockfd, buffer, server_address); - if (received_bytes == 0) continue; - sscanf(buffer, "DATA %ld %ld\n", &recv_pos, &recv_len); - if (recv_pos < bytes_writen) continue; - - int pos = (recv_pos - bytes_writen) / DATAGRAM_LEN; - pos = (pos + w.first_pos) % w.size; - if (!w.uptodate[pos]) { - for (int i = 0; i < recv_len; i++) { - w.ar[pos][i] = buffer[i + received_bytes - recv_len]; - } - w.uptodate[pos] = true; - } - update_file(fd, &w, &bytes_writen, &remaining_bytes); - } - - if (prev_len != bytes_writen) { - prev_len = bytes_writen; - printf("%.3f%%\n", 100.0 * (float)(bytes_writen) / (float)(remaining_bytes+bytes_writen)); - } - } - destroy_window(&w); - fclose(fd); -} - -int main(int argc, char *argv[]) { - if (argc != 5) { - printf("Usage:\n\t%s [server ip] [server port] [output file name] [file size]\n", argv[0]); - return -1; - } - - int sockfd = get_socket(); - struct sockaddr_in server_address; - bzero(&server_address, sizeof(server_address)); - server_address.sin_family = AF_INET; - if (!inet_pton(AF_INET, argv[1], &server_address.sin_addr)) { - fprintf(stderr, "Invalid ip address: %s\n", argv[1]); - return -1; - } - server_address.sin_port = htons(atoi(argv[2])); - if (server_address.sin_port == 0) { - fprintf(stderr, "Invalid port: %s\n", argv[2]); - return -1; - } - - size_t file_len = atoi(argv[4]); - if (file_len == 0) { - printf("File len is 0, nothing to do here.\n"); - return 0; - } - - receive_file(sockfd, server_address, argv[3], file_len); -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia3/utils.c b/Semestr 4/sieci/pracownia3/utils.c deleted file mode 100644 index 4c2f449..0000000 --- a/Semestr 4/sieci/pracownia3/utils.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Projekt: Transport - * Autor: Franciszek Malinka 316093 - */ - -#include "utils.h" -#include -#include -#include -#include -#include -#include -#include - -size_t min(size_t x, size_t y) { return (x -#include - -#define NS_TO_MS(X) ((long)(X) / (long)1000000) -#define S_TO_MS(X) ((long)(X) * (long)1000) - -size_t min(size_t x, size_t y); - -int get_socket(); - -long get_time_interval(struct timespec start, struct timespec finish); - -int poll_socket_modify_timeout(int sockfd, int *timeout); - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia3/window.c b/Semestr 4/sieci/pracownia3/window.c deleted file mode 100644 index c8bffad..0000000 --- a/Semestr 4/sieci/pracownia3/window.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Projekt: Transport - * Autor: Franciszek Malinka 316093 - */ - -#include "window.h" -#include -#include - -void init_window(window_t *w, int window_size, int window_width) { - w->ar = malloc(window_size * sizeof(char *)); - for (int i = 0; i < window_size; i++) - w->ar[i] = malloc(window_width * sizeof(char)); - w->uptodate = malloc(window_size); - bzero (w->uptodate, window_size); - w->first_pos = 0; - w->size = window_size; -} - -void destroy_window(window_t *w) { - for (int i = 0; i < w->size; i++) - free(w->ar[i]); - free(w->ar); - free(w->uptodate); -} - -void shift_while_uptodate(window_t *w) { - while (w->uptodate[w->first_pos]) { - w->uptodate[w->first_pos] = false; - w->first_pos = (w->first_pos + 1) % w->size; - } -} - -void shift(window_t *w) { - w->uptodate[w->first_pos] = false; - w->first_pos = (w->first_pos + 1) % w->size; -} - -void update(window_t *w, int pos, char *buffer, size_t buf_size) { - pos = (w->first_pos + pos) % w->size; - for (int i = 0; i < buf_size; i++) w->ar[pos][i] = buffer[i]; - w->uptodate[pos] = true; -} \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia3/window.h b/Semestr 4/sieci/pracownia3/window.h deleted file mode 100644 index 63e89cc..0000000 --- a/Semestr 4/sieci/pracownia3/window.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef WINDOW_H -#define WINDOW_H - -#include -#include - -typedef struct { - char **ar; - bool *uptodate; - int size; - int first_pos; -} window_t; - -void init_window(window_t *w, int window_size, int window_width); - -void destroy_window(window_t *w); - -void shift_while_uptodate(window_t *w); - -void shift(window_t *w); - -void update(window_t *w, int pos, char *buffer, size_t buf_size); - -#endif \ No newline at end of file diff --git a/Semestr 4/sieci/pracownia4/p4.pdf b/Semestr 4/sieci/pracownia4/p4.pdf deleted file mode 100644 index bdaa771..0000000 Binary files a/Semestr 4/sieci/pracownia4/p4.pdf and /dev/null differ diff --git a/Semestr 4/sieci/warsztaty1/w1.pdf b/Semestr 4/sieci/warsztaty1/w1.pdf deleted file mode 100644 index 5b50091..0000000 Binary files a/Semestr 4/sieci/warsztaty1/w1.pdf and /dev/null differ diff --git a/Semestr 4/sieci/warsztaty2/w2.pdf b/Semestr 4/sieci/warsztaty2/w2.pdf deleted file mode 100644 index 60cdc33..0000000 Binary files a/Semestr 4/sieci/warsztaty2/w2.pdf and /dev/null differ diff --git a/Semestr 4/sieci/warsztaty3/w3.pdf b/Semestr 4/sieci/warsztaty3/w3.pdf deleted file mode 100644 index b0266ad..0000000 Binary files a/Semestr 4/sieci/warsztaty3/w3.pdf and /dev/null differ diff --git a/Semestr 4/sieci/warsztaty4/w4.pdf b/Semestr 4/sieci/warsztaty4/w4.pdf deleted file mode 100644 index 1d6b54d..0000000 Binary files a/Semestr 4/sieci/warsztaty4/w4.pdf and /dev/null differ diff --git a/Semestr 4/sieci/warsztaty5/w5.pdf b/Semestr 4/sieci/warsztaty5/w5.pdf deleted file mode 100644 index e55fb7b..0000000 Binary files a/Semestr 4/sieci/warsztaty5/w5.pdf and /dev/null differ diff --git a/Semestr 4/sieci/warsztaty6/w6.pdf b/Semestr 4/sieci/warsztaty6/w6.pdf deleted file mode 100644 index 2f6b6c9..0000000 Binary files a/Semestr 4/sieci/warsztaty6/w6.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec1.pdf b/Semestr 4/sieci/wyklady/lec1.pdf deleted file mode 100644 index 5da8f03..0000000 Binary files a/Semestr 4/sieci/wyklady/lec1.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec2.pdf b/Semestr 4/sieci/wyklady/lec2.pdf deleted file mode 100644 index edb1398..0000000 Binary files a/Semestr 4/sieci/wyklady/lec2.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec3.pdf b/Semestr 4/sieci/wyklady/lec3.pdf deleted file mode 100644 index ae48ec2..0000000 Binary files a/Semestr 4/sieci/wyklady/lec3.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec4.pdf b/Semestr 4/sieci/wyklady/lec4.pdf deleted file mode 100644 index 352b71d..0000000 Binary files a/Semestr 4/sieci/wyklady/lec4.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec5.pdf b/Semestr 4/sieci/wyklady/lec5.pdf deleted file mode 100644 index 3a7b39b..0000000 Binary files a/Semestr 4/sieci/wyklady/lec5.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec6.pdf b/Semestr 4/sieci/wyklady/lec6.pdf deleted file mode 100644 index 04975ce..0000000 Binary files a/Semestr 4/sieci/wyklady/lec6.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec7.pdf b/Semestr 4/sieci/wyklady/lec7.pdf deleted file mode 100644 index 0b28c4d..0000000 Binary files a/Semestr 4/sieci/wyklady/lec7.pdf and /dev/null differ diff --git a/Semestr 4/sieci/wyklady/lec8.pdf b/Semestr 4/sieci/wyklady/lec8.pdf deleted file mode 100644 index a4fbb9c..0000000 Binary files a/Semestr 4/sieci/wyklady/lec8.pdf and /dev/null differ -- cgit v1.2.3