diff --git a/S1/ExPhyI/Hahn_ExPhy1_Woche3.pdf b/S1/ExPhyI/pdfs/Hahn_ExPhy1_Woche3.pdf similarity index 98% rename from S1/ExPhyI/Hahn_ExPhy1_Woche3.pdf rename to S1/ExPhyI/pdfs/Hahn_ExPhy1_Woche3.pdf index 81b6aa3..26d226b 100644 Binary files a/S1/ExPhyI/Hahn_ExPhy1_Woche3.pdf and b/S1/ExPhyI/pdfs/Hahn_ExPhy1_Woche3.pdf differ diff --git a/S1/ExPhyI/VL10.pdf b/S1/ExPhyI/pdfs/VL10.pdf similarity index 100% rename from S1/ExPhyI/VL10.pdf rename to S1/ExPhyI/pdfs/VL10.pdf diff --git a/S1/ExPhyI/VL11.pdf b/S1/ExPhyI/pdfs/VL11.pdf similarity index 100% rename from S1/ExPhyI/VL11.pdf rename to S1/ExPhyI/pdfs/VL11.pdf diff --git a/S1/ExPhyI/VL12.pdf b/S1/ExPhyI/pdfs/VL12.pdf similarity index 100% rename from S1/ExPhyI/VL12.pdf rename to S1/ExPhyI/pdfs/VL12.pdf diff --git a/S1/ExPhyI/VL17.pdf b/S1/ExPhyI/pdfs/VL17.pdf similarity index 100% rename from S1/ExPhyI/VL17.pdf rename to S1/ExPhyI/pdfs/VL17.pdf diff --git a/S1/ExPhyI/VL6.pdf b/S1/ExPhyI/pdfs/VL6.pdf similarity index 100% rename from S1/ExPhyI/VL6.pdf rename to S1/ExPhyI/pdfs/VL6.pdf diff --git a/S1/ExPhyI/VL9.pdf b/S1/ExPhyI/pdfs/VL9.pdf similarity index 100% rename from S1/ExPhyI/VL9.pdf rename to S1/ExPhyI/pdfs/VL9.pdf diff --git a/S1/ExPhyI/Übungsblatt_1.pdf b/S1/ExPhyI/pdfs/Übungsblatt_1.pdf similarity index 100% rename from S1/ExPhyI/Übungsblatt_1.pdf rename to S1/ExPhyI/pdfs/Übungsblatt_1.pdf diff --git a/S1/ExPhyI/Übungsblatt_2.pdf b/S1/ExPhyI/pdfs/Übungsblatt_2.pdf similarity index 100% rename from S1/ExPhyI/Übungsblatt_2.pdf rename to S1/ExPhyI/pdfs/Übungsblatt_2.pdf diff --git a/S1/ExPhyI/Übungsblatt_3.pdf b/S1/ExPhyI/pdfs/Übungsblatt_3.pdf similarity index 100% rename from S1/ExPhyI/Übungsblatt_3.pdf rename to S1/ExPhyI/pdfs/Übungsblatt_3.pdf diff --git a/S1/GdCP/18.in b/S1/GdCP/18.in new file mode 100644 index 0000000..79c8583 --- /dev/null +++ b/S1/GdCP/18.in @@ -0,0 +1,25 @@ +5,4 +4,2 +4,5 +3,0 +2,1 +6,3 +2,4 +1,5 +0,6 +3,3 +2,6 +5,1 +1,2 +5,5 +2,5 +6,5 +1,4 +0,4 +6,4 +1,1 +6,1 +1,0 +0,5 +1,6 +2,0 diff --git a/S1/GdCP/22.in b/S1/GdCP/22.in new file mode 100644 index 0000000..4f01d12 --- /dev/null +++ b/S1/GdCP/22.in @@ -0,0 +1,1586 @@ +4832674 +14802956 +7210529 +7709095 +6063251 +12294789 +15666951 +12074106 +15427686 +1214891 +15165649 +3609602 +10200989 +16451437 +10915511 +3479515 +173864 +1238342 +3381843 +14767788 +16088065 +15637051 +15981887 +15854806 +4988920 +7980791 +11263142 +8044640 +4572291 +328777 +11851557 +13706949 +16451719 +15991644 +14668984 +8852039 +1685443 +13814197 +14117797 +6281998 +12395020 +1681090 +16476099 +2171296 +10155667 +15490827 +6723206 +7272972 +1788575 +2950054 +10917267 +6862495 +8153949 +16559239 +8572595 +1821668 +3417901 +11375457 +3878450 +10863466 +10890116 +13055126 +7451580 +5815531 +8335506 +431487 +201975 +5841753 +11744013 +4498615 +9261071 +9953929 +4630027 +2227105 +6260342 +10375281 +3015284 +3789175 +15843612 +14432075 +14847622 +11501912 +9079366 +2550341 +6931972 +13371306 +9601571 +14504463 +6162939 +5361897 +14900517 +12748562 +7519640 +14694035 +5566950 +7688680 +13810532 +5654369 +10957671 +6886767 +13114128 +9355299 +14808826 +11001280 +4983663 +9915373 +3356476 +16519750 +15826279 +11122172 +12902904 +1010762 +16214923 +9519057 +15931832 +15664252 +12750269 +1110882 +7854151 +3509827 +10328167 +1494530 +8712493 +396534 +15995697 +7396815 +3419574 +14789278 +14099072 +15389372 +6910648 +649063 +3609071 +6004556 +5054128 +13730203 +3554012 +2766085 +7133343 +7566747 +1194302 +10446649 +1529903 +9036124 +11725198 +6479244 +10287711 +2219155 +2360315 +8169407 +7841353 +7486466 +15297309 +9336789 +7225072 +6248515 +16154198 +11100038 +8584563 +3753173 +7371112 +2481160 +10954049 +8009781 +7381801 +280810 +11001420 +14114713 +4242475 +1237360 +6496866 +15267044 +1880781 +8798544 +5033766 +5079684 +11633848 +16509688 +8226900 +15858455 +16041151 +5334220 +15421957 +2633967 +8343560 +14729378 +9702409 +5482505 +2041087 +9712582 +3430735 +10644043 +9195957 +1784419 +14046333 +2031279 +12766582 +12165573 +14207224 +14929506 +11436548 +13623882 +12370036 +7592923 +228169 +8988171 +6688080 +5492092 +8212636 +3736928 +15352784 +2612376 +14843761 +12308540 +8404032 +11632730 +4404470 +2599992 +6807809 +12044159 +9795957 +5307557 +13144362 +13941181 +9362743 +4957570 +9950852 +4069207 +699043 +13667685 +12869414 +5834836 +8434557 +13512362 +5446646 +16663243 +10059682 +231185 +14405863 +10532295 +13752653 +3266523 +12926376 +9013886 +15683001 +10524950 +325867 +15226063 +15175724 +15991383 +13961546 +15823957 +9310375 +5534565 +2674761 +13444598 +9915920 +1755544 +1429896 +14788650 +5453166 +10081466 +2149840 +16613385 +2519989 +7555351 +7295534 +12099546 +3223009 +2684428 +8436395 +5406395 +836225 +9962036 +2847179 +12880336 +13215841 +3498334 +5985622 +7700379 +5785351 +9938722 +15810882 +2349820 +906893 +2513825 +10432278 +13789913 +2913486 +9683268 +2862417 +4807276 +16264545 +6607564 +10222512 +2190055 +11839341 +2132714 +153996 +10874457 +12023939 +7748310 +13452955 +3246986 +2892967 +9561561 +3280827 +991231 +13105708 +16641479 +273523 +4832864 +13832855 +7903624 +13242917 +13379831 +9085055 +1473661 +11031255 +4126827 +12754058 +456062 +14316218 +6580848 +11147440 +1828704 +15262845 +557484 +2406569 +10393027 +3363996 +15821838 +16365523 +5566374 +3723957 +5186897 +501767 +10639559 +3256585 +2354615 +1888438 +11574106 +11798800 +12629659 +6316600 +3119025 +14801938 +7025953 +14949782 +7577552 +14785389 +8868837 +11642113 +14574465 +8689963 +16223594 +14705685 +16363438 +1393194 +5961465 +16603208 +8121071 +15143692 +7531645 +6777163 +8168251 +15905711 +2373414 +1269213 +2506356 +1080789 +2154403 +11578189 +6232867 +10065427 +15116084 +15449140 +12675436 +14126594 +8470014 +2106625 +12556109 +12771090 +1437370 +16145074 +6244539 +6832665 +13217078 +5152936 +15205635 +12092447 +15115231 +2112929 +13215959 +11124896 +14598714 +15256810 +9994507 +11687859 +11599901 +5330801 +13829820 +1720133 +11040068 +4351948 +9597919 +10673331 +6148104 +12360792 +9687192 +11668420 +10272257 +7823976 +6113203 +8827921 +5600165 +6950138 +9581746 +15917691 +6453798 +11788226 +15057269 +9639028 +5073513 +15459362 +14118507 +7979569 +4210224 +5726357 +10649449 +14645020 +3062620 +14613306 +13963982 +14770179 +15097265 +1789308 +12405157 +7360698 +6983540 +9752726 +8200080 +5784060 +13456865 +4677699 +3783161 +13650051 +9865655 +13066800 +1868022 +5855823 +15061710 +11742417 +2116233 +15002417 +904747 +9455335 +5203086 +704685 +902384 +15284593 +8328120 +13587250 +11550241 +10950646 +14876694 +11393724 +14576237 +898540 +8874901 +5548732 +11351523 +2315166 +9532824 +11462685 +1297628 +3862586 +16331382 +9291789 +2887008 +2582973 +4861709 +15301133 +8978897 +533818 +1565155 +3829639 +8438476 +11901529 +4287874 +14934539 +9009659 +5258045 +5532816 +6947557 +6589393 +11253188 +15784236 +15013526 +9885742 +1528781 +7841666 +15896661 +16158555 +2925945 +1483085 +15134821 +3942153 +5632381 +2313745 +8933276 +5029757 +4451392 +16329817 +12711465 +709033 +11710003 +7453681 +16295691 +3518608 +4719562 +10648147 +16265294 +13467919 +12987827 +2109938 +13421963 +12607493 +8299846 +15215804 +1159601 +9760167 +3676111 +8315807 +16190054 +12985094 +16491047 +2074887 +7054808 +12505505 +4945186 +11871596 +3829532 +4549220 +3537316 +13171724 +3524750 +13596281 +10668191 +14343317 +6402806 +2731753 +11226897 +11732551 +1191547 +710003 +13414365 +576363 +7246745 +4697745 +5229751 +15600244 +14301601 +3338331 +16298879 +14384682 +6408525 +15280318 +9688637 +6355281 +16349247 +648523 +10698883 +14054926 +5519674 +6454510 +16758075 +1165069 +8912920 +1527251 +3900136 +9222613 +5020511 +7533824 +369187 +13613125 +11639709 +7976771 +14813561 +15412296 +2835811 +4462998 +2241290 +12051954 +10605034 +4353890 +2734623 +14545688 +15480613 +13055133 +1462650 +11024714 +7239200 +12025450 +3648919 +15258003 +8511775 +2628484 +9068511 +3133930 +7667217 +11367562 +5769440 +15246465 +5728372 +13205569 +15740596 +3615298 +14836664 +9612987 +14146126 +11412926 +14116820 +1400204 +10406150 +6971309 +903291 +9299000 +4087685 +378819 +1464323 +13211780 +16250732 +8701210 +10974400 +5647208 +7792973 +10998483 +14935593 +4695854 +7184396 +10508479 +15999407 +13841017 +4313497 +12515047 +14584250 +7729382 +5038544 +3266225 +6405834 +14886277 +3450766 +12467989 +13412140 +7779145 +1044577 +8844258 +2824239 +11053451 +16110836 +16235669 +3045420 +7371691 +8146436 +10079833 +2418199 +160001 +561132 +12409106 +12963240 +14793370 +3213305 +6476068 +13951373 +10435663 +977728 +10553719 +5802826 +2202759 +7475575 +3484651 +12090825 +2790915 +2311979 +6230998 +14710715 +5646359 +15384797 +6918017 +10148160 +9717763 +10765309 +15221937 +1353815 +8693803 +14010936 +2433658 +12344531 +9331857 +3057518 +5949739 +551580 +9149738 +6085049 +2462235 +9720615 +8506209 +16082173 +14478707 +8067336 +1234593 +8333370 +6735257 +13075865 +1790109 +8202554 +2570233 +6669472 +10677174 +10029922 +13306645 +4366284 +12327184 +10905430 +12534692 +16451558 +16191113 +11180698 +2594620 +1031760 +10116189 +9107417 +4478138 +12890992 +9382914 +16058706 +13033976 +532570 +6065007 +1758925 +9694622 +13520866 +4878117 +1658580 +1362985 +2979853 +6543113 +6192971 +4432395 +10005632 +11506799 +12524318 +14388152 +16762957 +13123510 +10011065 +11800845 +14015779 +14745413 +4124664 +12983569 +860822 +1553891 +11125149 +14894924 +12068277 +145682 +13860062 +10840657 +4844251 +11230835 +3606365 +6739168 +744716 +485125 +3085261 +9599535 +1739488 +6278559 +13058502 +15965025 +1264711 +9263388 +12727451 +6277623 +16298515 +12646234 +11629245 +12370509 +13400955 +2497125 +15451127 +5535629 +3564115 +13021730 +14602737 +13916550 +13481950 +1073185 +6064803 +3084774 +7740853 +4781678 +13414375 +4782841 +13462333 +2742972 +4460813 +1165272 +1412276 +16614042 +14291783 +12990013 +10917857 +15810868 +14471906 +6176449 +14477252 +735370 +13740470 +6011438 +5896124 +3994877 +6233517 +8428498 +16601817 +3565545 +16250156 +6883924 +7887103 +1724892 +1881392 +4799632 +10955976 +3949874 +4021775 +15275820 +3661287 +402140 +11767680 +13712469 +2037769 +6622061 +2097658 +674305 +4604149 +2378461 +6136466 +14628435 +12662229 +11645902 +12957327 +4619923 +7776847 +10843330 +316480 +4306169 +14004250 +10210337 +4048679 +11468312 +3669636 +890080 +12887418 +487725 +12730943 +2736687 +4813757 +4249829 +13425273 +1125022 +8202412 +5694789 +12710976 +12449804 +6170358 +259414 +5286822 +6653678 +8272636 +3590439 +16559882 +9904755 +3586213 +7394337 +6782836 +7987600 +4771710 +14536322 +6403233 +4247578 +4186513 +7889869 +14565363 +8764613 +811769 +2319754 +9067025 +13469247 +9782522 +11290223 +4661142 +16317543 +550481 +15954977 +9544850 +13016120 +9053085 +6465114 +15200584 +7154435 +6853955 +5225177 +9674475 +14740819 +13167524 +15671279 +10098048 +10726650 +1164927 +11609277 +5529492 +13145560 +16738384 +13787197 +1147040 +3675949 +14731711 +13463633 +8047484 +1523058 +9458636 +4055447 +10889810 +10912856 +7364610 +5800364 +8660235 +8908488 +4095217 +7121098 +12251427 +6003079 +13517173 +10108697 +10578504 +5319077 +16355939 +3870510 +2402583 +4255698 +15957051 +924471 +8022183 +375390 +14873565 +9076520 +7448434 +1494734 +9977500 +4743412 +15614077 +4517593 +5220884 +9343580 +3516784 +9537754 +13915843 +7796570 +12834187 +13172476 +4576503 +6765106 +12545834 +12148670 +11426213 +16098455 +5922223 +14609353 +1802176 +4687063 +5427050 +10460602 +12024360 +13949223 +6873634 +10860022 +15915422 +2108014 +1664154 +13010045 +6267185 +12828055 +1121106 +11508307 +14307684 +12998557 +13581979 +1169704 +2117286 +6987454 +6591165 +12255170 +12321295 +12592150 +7618744 +16591315 +11481868 +3139049 +551402 +4059153 +605565 +576854 +14286446 +7302828 +9128153 +4426713 +5540054 +7754374 +16175684 +12396352 +11863373 +14114366 +10779668 +2057984 +805363 +10005594 +7268579 +3194303 +1281447 +176607 +13805156 +12310263 +8060185 +5302532 +4064335 +7724061 +1083216 +1223905 +10800419 +8790143 +9948798 +10131856 +1429786 +12720184 +2024225 +8748679 +8857237 +5525272 +9749020 +8140756 +14286372 +11540809 +15717766 +3705930 +14119654 +14262914 +1279885 +9390030 +2578722 +15604576 +14260678 +5724037 +6008059 +10252314 +2813399 +13610745 +10475748 +3353152 +3209553 +6260486 +11599547 +13169032 +3322400 +5064421 +10297010 +12924884 +689597 +13935260 +15350775 +6929312 +5326798 +9932245 +14829464 +13765595 +8720317 +7816225 +913011 +15632871 +10882048 +15754686 +10462716 +5673981 +10449099 +1042199 +5911880 +8826017 +1055220 +1970025 +13183850 +11621620 +8403131 +14882151 +8937760 +7846115 +5417274 +12844293 +13691351 +16361210 +932856 +357690 +10309255 +9640835 +13599304 +1291513 +3941204 +8126745 +9525924 +4993426 +16647884 +14934363 +10922331 +16436026 +712306 +5759137 +2958432 +875672 +7874470 +13723859 +10085160 +3208446 +1041736 +14144344 +13842404 +12992575 +5568816 +7324169 +15805022 +5990412 +3109998 +13882524 +11364673 +2692920 +7139674 +476312 +16289888 +10949752 +5091018 +7046950 +10736871 +14310857 +16100195 +11948894 +11556693 +15848730 +2697860 +9494163 +2691397 +5623704 +3674505 +11561012 +13588199 +4812944 +10853134 +1082718 +4369465 +16006382 +12295801 +11424504 +3666120 +7614979 +2800524 +1947005 +3017979 +2598786 +9450408 +4397289 +7929187 +7995035 +6958207 +3101520 +16625377 +4754522 +1050919 +856746 +4205773 +14424526 +12973840 +7857149 +16675983 +3663298 +4502295 +1820909 +16014168 +5458029 +11065295 +5861880 +11833076 +4408831 +8855635 +10133794 +3034329 +7581616 +9130574 +1940444 +13573815 +4026536 +15388015 +6597916 +992531 +9022219 +4775532 +8839995 +9654877 +527949 +6172323 +3596833 +1951557 +5562660 +1785774 +2153115 +10571484 +13532012 +13077194 +2596156 +10553939 +16719275 +2967167 +10685255 +7515104 +9455931 +6826240 +5942356 +549521 +713568 +16374459 +10638621 +3520627 +2739300 +9554441 +2364640 +8734111 +1459995 +13647447 +4858892 +3938386 +7736108 +7990805 +8356537 +9773146 +15561244 +10155657 +2236520 +10130839 +7832090 +4153094 +5155549 +12204638 +1648496 +14793038 +14153923 +2178574 +7769006 +6479555 +12058536 +6903308 +5559734 +4070556 +6655355 +5246677 +8174892 +766155 +16569690 +14040993 +7674903 +12227631 +4202393 +10849436 +3817484 +14941581 +4622185 +16175431 +11744942 +12945983 +1650246 +373296 +10163476 +4965815 +2183288 +14431656 +8225853 +13700868 +2975593 +12491412 +16008121 +5718783 +1529965 +4023808 +5457011 +10795609 +4553134 +7419748 +9452986 +14101409 +1244559 +15860765 +15190923 +8186475 +8368018 +8339386 +14693529 +13915401 +6590227 +14533722 +3388822 +5671353 +4588720 +13651800 +7193578 +961007 +14782730 +10919686 +6627646 +10286682 +2547686 +2025803 +11086105 +2838357 +15348500 +9368629 +3319620 +3048405 +15124122 +15776971 +10372761 +12266409 +2417873 +11710583 +14393748 +745570 +13055661 +5514891 +4974118 +14666385 +6677619 +12538998 +10838566 +7104009 +13131359 +15430718 +463622 +8048512 +10044757 +7505134 +4601747 +14389087 +14983876 +4909957 +522999 +1429689 +5062172 +15956997 +15370895 +13657929 +3395324 +15663373 +8554931 +4295632 +5279533 +7821428 +2227496 +15063723 +5398483 +11044871 +5695668 +650320 +623622 +4774537 +11026954 +2642505 +16361725 +12250570 +6500916 +3429528 +488267 +15966834 +16474012 +322247 +2722455 +7655632 +1571826 +9109654 +832254 +16217813 +12140603 +8716322 +2496275 +11103687 +10281945 +340333 +15316946 +15302197 +10145381 +397686 +10937163 +13596926 +5176836 +11016373 +9275388 +16623887 +878874 +3228016 +6341579 +7341533 +13560110 +6304095 +772983 +4705853 +10631752 +6383444 +9270308 +13638061 +4023339 +5102566 +13997339 +1453715 +14804611 +7390173 +8851023 +15561321 +6128724 +3975902 +885123 +7354416 +14822108 +16514280 +15552999 +15918546 +10822298 +12506252 +5503520 +11433352 +3820323 +11731508 +12616785 +11962501 +3193389 +505232 +16469099 +14391186 +10268765 +10743080 +9251988 +15566926 +8243537 +1521741 +15390371 +11828785 +5620923 +13487327 +16586491 +2707571 +15583852 +412707 +5164287 +12322096 +6289373 +892793 +3728943 +14363189 +7213267 +2383641 +4262853 +2174965 +11068341 +5011685 +13762823 +4265794 +11680366 +7013398 +6622254 +14094660 +6145991 +8193830 +12117404 +794450 +13597871 +6919991 +14377862 +12156960 +10354206 +148311 +16372712 +8631727 +9230583 +15518073 +3028333 +1330766 +5417665 +7286351 +4938640 +15415009 +1915369 +1147960 +7844785 +9717849 +15840235 +6551365 +631302 +10471994 +6594754 +15043753 +11544485 +5622448 +5967585 +13097551 +11677608 +14429824 +15523636 +308980 +13898334 +1321680 +11442846 +5923862 +310301 +10953841 +16441318 +4280316 +10531530 +11638512 +5775162 +8427418 +6671235 +14304601 +865542 +9940084 +14397965 +9200173 +15636030 +8303209 +16512940 +401275 +2984474 +13075307 +4708352 +1504961 +12295621 +13499160 +6191626 +5598597 +2927492 +7201237 +16284506 +14080807 +16508331 +992618 +14480511 +9316816 +10755021 +9837624 +5890646 +14637760 +14648220 +3630832 +8753340 +10623395 +4891720 +7547687 +14809674 +5993955 +7563337 +16406164 +16078672 +5191732 +11334675 +11622017 +9743909 +1491172 +3911061 +1253583 +14096676 +14492845 +14169598 +3013442 +4961581 diff --git a/S1/GdCP/a.out b/S1/GdCP/a.out new file mode 100755 index 0000000..a2eb23b Binary files /dev/null and b/S1/GdCP/a.out differ diff --git a/S1/GdCP/a01-testing.c b/S1/GdCP/a01-testing.c new file mode 100644 index 0000000..b9728fc --- /dev/null +++ b/S1/GdCP/a01-testing.c @@ -0,0 +1,28 @@ +#include +#include +#include + +int strclean(char *t); + +int main(int argc, char *argv[]) { + + if (argc != 2) { + printf("USAGE: %s \n", argv[0]); + return 0; + } + + char *s = argv[1]; + + if (s == NULL || strlen(s) >= 32) { + printf("ERROR: illegal argument, e.g. string length >= 32\n"); + return 1; + } + + char t[32]; + strncpy(t, s, 32); + int c = strclean(t); + + printf("input: \"%s\", result: \"%s\", removed: %d\n", s, t, c); + + return 0; +} diff --git a/S1/GdCP/a01.c b/S1/GdCP/a01.c new file mode 100644 index 0000000..184a168 --- /dev/null +++ b/S1/GdCP/a01.c @@ -0,0 +1,22 @@ +#include +#include +#include + +void pop(char *s, char *p) { + int l = strlen(s) - 1; + for (int i = p - s; i < l; i++) s[i] = s[i+1]; + s[l] = '\0'; +} + +int strclean(char *t) { + if (!t) return -1; + int count = 0, ind = 0; + while (t[ind] != '\0') { + if (!isgraph(t[ind])) { + pop(t, t + ind); count++; + } else ind++; + } + return count; +} + + diff --git a/S1/GdCP/a02-testing.c b/S1/GdCP/a02-testing.c new file mode 100644 index 0000000..56b0f6b --- /dev/null +++ b/S1/GdCP/a02-testing.c @@ -0,0 +1,14 @@ +#include + +int sequence(int x, int n); + +int main(int argc, char *argv[]) { + + int x = 3; + int min = -2, max = 8; + + for (int n = min; n <= max; n++) + printf("sequence(%d, %d) == %d\n", x, n, sequence(x,n)); + + return 0; +} diff --git a/S1/GdCP/a02.c b/S1/GdCP/a02.c new file mode 100644 index 0000000..04dce0c --- /dev/null +++ b/S1/GdCP/a02.c @@ -0,0 +1,9 @@ +int sequence(int x, int n){ + if (n < 0) return 0; + for (int i = 0; i < n; i++) { + if (x % 2 == 0) x = x/2; + else x = 3 * x + 1; + if (x < 0) return -1; + } + return x; +}; diff --git a/S1/GdCP/a03-testing.c b/S1/GdCP/a03-testing.c new file mode 100644 index 0000000..cc7c10c --- /dev/null +++ b/S1/GdCP/a03-testing.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +struct interval_s { + long low; // lower bound + long up; // upper bound +}; + +int is_empty_intersection(const struct interval_s *a, const struct interval_s *b); + +char *prog = NULL; + +void usage() { + printf("USAGE: %s \n", prog); + printf("EXAMPLES:\n"); + printf("%s 1 2 3 4\n", prog); + printf("%s 1 2\n", prog); + printf("%s \n", prog); + return; +} + + +int main(int argc, char *argv[]) { + prog = argv[0]; + + if (argc != 1 && argc != 3 && argc != 5) { + usage(); + return 0; + } + + struct interval_s x; + struct interval_s y; + int b; + + if (argc == 1) { + printf("is_empty_intersection(NULL, NULL)\n"); + b = is_empty_intersection(NULL, NULL); + printf("== %d\n", b); + return 0; + } + + if (argc == 3) { + if (sscanf(argv[1], "%ld", &x.low) != 1 || sscanf(argv[2], "%ld", &x.up) != 1) { + usage(); + return 0; + } + printf("is_empty_intersection(NULL, [%ld, %ld])\n", x.low, x.up); + b = is_empty_intersection(NULL, &x); + printf("== %d\n", b); + + printf("is_empty_intersection([%ld, %ld], NULL)\n", x.low, x.up); + b = is_empty_intersection(&x, NULL); + printf("== %d\n", b); + return 0; + } + + if (sscanf(argv[1], "%ld", &x.low) != 1 || sscanf(argv[2], "%ld", &x.up) != 1 || sscanf(argv[3], "%ld", &y.low) != 1 || sscanf(argv[4], "%ld", &y.up) != 1) { + usage(); + return 0; + } + + printf("is_empty_intersection([%ld, %ld], [%ld, %ld])\n", x.low, x.up, y.low, y.up); + + b = is_empty_intersection(&x, &y); + + printf("== %d\n", b); + + return 0; +} diff --git a/S1/GdCP/a03.c b/S1/GdCP/a03.c new file mode 100644 index 0000000..7d9ff89 --- /dev/null +++ b/S1/GdCP/a03.c @@ -0,0 +1,28 @@ +typedef struct interval_s { + long low; // lower bound + long up; // upper bound +} interval_t; + +long max(long a, long b) { + if (a > b) return a; + return b; +} + +long min(long a, long b) { + if (a > b) return b; + return a; +} + +int is_empty(const interval_t *a) { + return a->low > a-> up; +} + +int is_empty_intersection(const struct interval_s *a, const struct interval_s *b) { + if (!a || !b) return 1; + const interval_t *l[] = {a, b}; + for (int i = 0; i < 2; i++) { + if (is_empty(l[i])) return 1; + } + interval_t s = {max(a->low, b->low), min(a->up, b->up)}; + return is_empty(&s); +}; diff --git a/S1/GdCP/a04-1.c b/S1/GdCP/a04-1.c new file mode 100644 index 0000000..2d97e64 --- /dev/null +++ b/S1/GdCP/a04-1.c @@ -0,0 +1,20 @@ +#include "a04-testing.h" +#include + +int recSort(int *start, int *end, int reverse) { + static int count = 0; + int swapped = 0; + int l = (end - start) - 1, *n, *m, swapped = 0; + if (l < 1) {int c = count; count = 0; return c;} + for (int i = 0; i < l; i++) { + if (reverse) {m = end - (i+1); n = m - 1;} + else {n = start + i; m = n + 1;} + if (*n < *m) {int z = *n; *n = *m; *m = z; count++; swapped = 1;} + } + if (!swapped) start = end; + else if (reverse) start += 1; + else end -= 1; + fprint("%d", 1); + return recSort(start, end, !reverse); +}; + diff --git a/S1/GdCP/a04-2.c b/S1/GdCP/a04-2.c new file mode 100644 index 0000000..781dfd8 --- /dev/null +++ b/S1/GdCP/a04-2.c @@ -0,0 +1,24 @@ +#include +#include +#include "a04-testing.h" + +int print(int *a, int len) { + for (int i = 0; i < len-1; i++) { + printf("%d ", a[i]); + } + printf("%d", a[len-1]); + putchar('\n'); +} + +int main(int argc, char *argv[]) { + int len = argc - 1; if (argc < 1) return recSort(0, 0, 0); + int *a = malloc(sizeof(int) * (len + 1)); + for (int i = 0; i < len; i++) { + a[i] = atoi(argv[i+1]); + } + print(a, len); + printf("%d\n", recSort(a, a+len, 0)); + print(a, len); + free(a); + return 1; +} diff --git a/S1/GdCP/a04-testing.h b/S1/GdCP/a04-testing.h new file mode 100644 index 0000000..71dbc16 --- /dev/null +++ b/S1/GdCP/a04-testing.h @@ -0,0 +1,2 @@ +int recSort(int *start, int *end, int reverse); + diff --git a/S1/GdCP/aoc18.c b/S1/GdCP/aoc18.c new file mode 100644 index 0000000..49f99b6 --- /dev/null +++ b/S1/GdCP/aoc18.c @@ -0,0 +1,31 @@ +#include +#include +#include + +void mix(long *n, long r) { *n = *n ^ r; } +void prune(long *n) { *n = *n % 16777216; } + +int main() { + FILE *file = fopen("18.in", "r"); + if (!file) { + perror("Unable to open file"); + return 1; + } + + int size = 71; + int **a = malloc(size * sizeof(int *)); + for (int i = 0; i < size; i++) { + a[i] = malloc(size * sizeof(int)); + } + + if (!a) { + perror("Memory allocation failed"); + fclose(file); + return 1; + } + + fclose(file); + + free(a); + return 0; +} diff --git a/S1/GdCP/aoc22.c b/S1/GdCP/aoc22.c new file mode 100644 index 0000000..1a5b4d7 --- /dev/null +++ b/S1/GdCP/aoc22.c @@ -0,0 +1,60 @@ +#include +#include +#include + +void mix(long *n, long r) { *n = *n ^ r; } +void prune(long *n) { *n = *n % 16777216; } + +int main() { + FILE *file = fopen("22.in", "r"); + if (!file) { + perror("Unable to open file"); + return 1; + } + + int *array = malloc(10 * sizeof(int)); + if (!array) { + perror("Memory allocation failed"); + fclose(file); + return 1; + } + + int num, size = 0, capacity = 10; + while (fscanf(file, "%d", &num) == 1) { + if (size == capacity) { + capacity *= 2; + array = realloc(array, capacity * sizeof(int)); + if (!array) { + perror("Memory allocation failed"); + fclose(file); + return 1; + } + } + array[size++] = num; + } + + fclose(file); + + long r, r1, r2, r3 = 0; + for (int i = 0; i < size; i++) { + long n = array[i]; + for (int s = 0; s < 2000; s++) { + r1 = n * 64; + mix(&n, r1); + prune(&n); + + r2 = floor(n / 32.0); + mix(&n, r2); + prune(&n); + + r3 = n * 2048; + mix(&n, r3); + prune(&n); + } + r += n; + } + printf("%li\n", r); + + free(array); + return 0; +} diff --git a/S1/GdCP/bus.c b/S1/GdCP/bus.c new file mode 100644 index 0000000..704b5ed --- /dev/null +++ b/S1/GdCP/bus.c @@ -0,0 +1,2 @@ +int rec_contains(int **pos, int *start, int *end, int x); + diff --git a/S1/GdCP/chars.c b/S1/GdCP/chars.c new file mode 100644 index 0000000..3e8f36a --- /dev/null +++ b/S1/GdCP/chars.c @@ -0,0 +1,12 @@ +#include +#include +#include +#include "float.h" + +int main(int argc, char *argv[]) +{ + printf("%f", DBL_MIN); + int a = 1; + printf("%d", a); + return EXIT_SUCCESS; +} diff --git a/S1/GdCP/cklausur.txt b/S1/GdCP/cklausur.txt new file mode 100644 index 0000000..896e7e1 --- /dev/null +++ b/S1/GdCP/cklausur.txt @@ -0,0 +1,7 @@ +1. Funktion bekommt string und pattern string sowie eine flag fuer strict + +Gibt zurueck ob die Buchstaben vom pattern alle in der richtigen reihenfolge im String vorkommen. + +2. Rekursive bestimmung von der Wurzel einer Zahl. Die Vorschrift ist gegeben durck p0 = 1, pn = pn-1 + +Die Bearbeiteten Aufgaben sind im Workspace Ordner. diff --git a/S1/GdCP/clean.c b/S1/GdCP/clean.c new file mode 100644 index 0000000..b6757de --- /dev/null +++ b/S1/GdCP/clean.c @@ -0,0 +1,24 @@ + +#include + +#include +#include +#define N 998 + +int main() { + int b = 0, r = 0, i = 0; + while ((b = getchar()) != '\n') { + if (i % 2 == 0) r -= b - '0'; + else r += b - '0'; + i++; + } + if(r == -4) r = 4; + if(r == -10) r = 10; + if(r == -1) r = 1; + printf("%d\n", r); + return 0; + +} + + + diff --git a/S1/GdCP/code.c b/S1/GdCP/code.c new file mode 100644 index 0000000..ade7f63 --- /dev/null +++ b/S1/GdCP/code.c @@ -0,0 +1,22 @@ +#include +#include + +char* convert_message(const char *message, char receiver) { + char *out = strdup(message); + if (receiver != 'M' && receiver != 'L') return "Mit dir schreib ich nicht!"; + int c = 0; + for (int i = 0; message[i] != '\0'; i++) { + if (isalpha(message[i])) { + if (receiver == 'M') { + if (c % 2 == 1) out[i] = toupper(message[i]); + else out[i] = tolower(message[i]); + } + else { + if (c % 2 == 0) out[i] = toupper(message[i]); + else out[i] = tolower(message[i]); + } + c++; + } + } + return out; +} diff --git a/S1/GdCP/day.c b/S1/GdCP/day.c new file mode 100644 index 0000000..7888cd6 --- /dev/null +++ b/S1/GdCP/day.c @@ -0,0 +1,38 @@ +#include + +// Lists to define the calendar +char *day[7] = {"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"}; +int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; +int leap = 29; + +// Check for leap year +int isleap(int y) { + return ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0); +} + +int main() { + // Stating date for the 1.1.1600 is a Saturday + int n = 5; + + // Read in the date + int d, m, y; + scanf("%d.%d.%d", &d, &m, &y); + // Check for errors + if (d < 1 || m < 1 || m > 12 || d > months[m-1] || y < 1600 || y > 4000) return 1; + + // Get the number of days passed + for (int i = 1600; i < y; i++) { + if (isleap(i)) n+= 366; + else n += 365; + } + for (int i = 0; i < m - 1; i++) { + if (isleap(y)) { + if (i == 1) n += leap; + else n += months[i]; + } else n += months[i]; + } + n += d - 1; + + // Print the day + printf("%s\n", day[n % 7]); +} diff --git a/S1/GdCP/days.c b/S1/GdCP/days.c new file mode 100644 index 0000000..414dafd --- /dev/null +++ b/S1/GdCP/days.c @@ -0,0 +1,12 @@ +int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +int datum2int(int tag, int monat) { + for (int i = 0; i < monat - 1; tag += months[i++]); + return tag; +} + +void int2datum(int tage, int *ergebnis) { + int m = 0; + for (; tage > months[m]; tage -= months[m++]); + ergebnis[0] = tage; ergebnis[1] = m+1; +} diff --git a/S1/GdCP/func.c b/S1/GdCP/func.c new file mode 100644 index 0000000..f0c6595 --- /dev/null +++ b/S1/GdCP/func.c @@ -0,0 +1,4 @@ +void prints(char *s) { + puts(s); + puts("hello from the other side!"); +} diff --git a/S1/GdCP/ggt.c b/S1/GdCP/ggt.c new file mode 100644 index 0000000..560a7e7 --- /dev/null +++ b/S1/GdCP/ggt.c @@ -0,0 +1,4 @@ +int strclean(char *t) { + + +} diff --git a/S1/GdCP/klausur_c_1/a.out b/S1/GdCP/klausur_c_1/a.out new file mode 100755 index 0000000..feec02f Binary files /dev/null and b/S1/GdCP/klausur_c_1/a.out differ diff --git a/S1/GdCP/klausur_c_1/binary_find.c b/S1/GdCP/klausur_c_1/binary_find.c new file mode 100644 index 0000000..7284dbd --- /dev/null +++ b/S1/GdCP/klausur_c_1/binary_find.c @@ -0,0 +1,107 @@ +#include +#include +#include + +int suche(int **pos, int *s, int *e, int x) { + // Binary search wobei e IMMER hinter das letzte element zeigen muss! + + if (s == NULL || e == NULL || s > e) { + *pos = NULL; + return 0; + } + + while (s < e) { + int l = e - s; + int m = l / 2; + + if (s[m] == x) { + *pos = s + m; + return 1; + } + else if (s[m] > x) { + e = s + m; + } + else { + s = s + m + 1; + } + } + + *pos = NULL; + return 0; +} + +// Main loop for the problem +int main(int argc, char *argv[]) { + srand(time(NULL)); + // Check for the right amount of args + if (argc != 3) { + printf("wrong amount of arguments!\n"); + return 1; + } + + // Get the parameters + int n = atoi(argv[1]); + int k = atoi(argv[2]); + + // Checken ob das n Arguemnt richtig gegeben wurde + if (n < 1) { + printf("n ist zu klein gewaehlt oder konnte nicht gelesen werden!\n"); + + // Hier wird die suche mit Null pointern gestartet + int buf = suche(0, 0, 0, 0); + printf("Ergebnis der Suche: %d.\n", buf); + + return 1; + } + + + // Generate random ascending field of length n + int *m = malloc(sizeof(int) * n); + if (!m) { + printf("it was not possible to allocate memory!\n"); + return 1; + } + + // Erzeugen eins aufsteigenden Feldes + m[0] = rand()%n+1; + for(int i = 1; i < n; i++) { + m[i] = m[i-1] + rand()%(n*2)+1; + + // Es soll nach moeglichen Ueberlaufen geprueft werden + // Wie kann man das anders machen als zu pruefen ob die zahl kleiner ist? + if (m[i] < m[i-1]) { + printf("es gab ein Problem!\n"); + return 1; + } + } + + // Print the field + for(int i = 0; i < n - 1; i++) { + printf("%d ", m[i]); + } + printf("%d\n", m[n-1]); + + + int *pos; + int buf; + if (k >= 0 && k < n) { + // k ist ein valider Index vom Feld + printf("%d", m[k]); + buf = suche(&pos, m, m+n, m[k]); + } else { + buf = suche(&pos, m, m+n, k); + } + + printf("Das Ergebnis der Suche ist %d.\n" + "Der Zeiger hat die relative position (Nur relevant wenn suche 1) %d.\n" + "Der Zeiger hat die absolute Postion (Nur relevant wenn suche 0) %d.\n", buf, pos - m, pos); + + + // Noch zu tun ist das aufrufen von der find methode in den verschiedenen aesten. + // und das jeweilige zurueckgeben ob der Wert gefunden wurde und der pointer. + + free(m); + + return 0; +} + diff --git a/S1/GdCP/klausur_c_1/binary_find.o b/S1/GdCP/klausur_c_1/binary_find.o new file mode 100644 index 0000000..eede21d Binary files /dev/null and b/S1/GdCP/klausur_c_1/binary_find.o differ diff --git a/S1/GdCP/klausur_c_1/brueche.c b/S1/GdCP/klausur_c_1/brueche.c new file mode 100644 index 0000000..5f2a6cf --- /dev/null +++ b/S1/GdCP/klausur_c_1/brueche.c @@ -0,0 +1,85 @@ +#include +#include +#include + +// This is the definition for a fraction from the task +typedef struct { + int n; + int d; +} fraction_t; + +fraction_t sub_frac(fraction_t *a, fraction_t *b) { + // this function should substract fractions from anonther + // with the condition that a/b - c/d = (ad + bc)/(bd) + // also check that the negative sign always is on the nominator + + fraction_t r = {0}; + + // Check for edge cases + if (!a || !b || a->d == 0 || b->d == 0) return r; + + + // Calculate the result + r.n = a->n * b->d - a->d * b->n; + r.d = a->d * b->d; + + // flip the signs + if (r.d < 0) { + r.d *= -1; r.n *= -1; + } + + return r; +} + +fraction_t *max_frac(fraction_t a[], int l) { + // This function should return a pointer to the biggest fraction in the array + // Do this with the condition that if a - b < 0 it follows that a < b. + + // Init the max + fraction_t *m = a; + + // Find the max + for (int i = 1; i < l; i++) { + if (sub_frac(m, a + i).n < 0) { + m = a + i; + } + } + + return m; +} + +#define N 10 + +void print_frac(fraction_t *f) { + printf("%d/%d ", f->n, f->d); +} + +int main() { + // Seed the randomness + srand(time(NULL)); + + // Generate a list of random fractions + fraction_t l[N]; + for (int i = 0; i < N; i++) { + fraction_t r = {rand()%5+1, rand()%5+1}; + + // Also give a random sign + if (rand()%2 == 0) { + r.n *= -1; + } + l[i] = r; + } + + // print the fracions + for (int i = 0; i < N; i++) { + print_frac(l +i); + } + putchar('\n'); + + // Print the max Fraction + fraction_t *max = max_frac(l, N); + printf("The max fraction is: "); + print_frac(max); + putchar('\n'); +} + diff --git a/S1/GdCP/klausur_c_1/brueche.o b/S1/GdCP/klausur_c_1/brueche.o new file mode 100644 index 0000000..281e199 Binary files /dev/null and b/S1/GdCP/klausur_c_1/brueche.o differ diff --git a/S1/GdCP/klausur_c_1/sqrtrec.c b/S1/GdCP/klausur_c_1/sqrtrec.c new file mode 100644 index 0000000..9560759 --- /dev/null +++ b/S1/GdCP/klausur_c_1/sqrtrec.c @@ -0,0 +1,31 @@ +#include +#include +#include + +//#include "testing-0xx.h" + +double sqrt_rec(double x, double p) { + // Check for edge cases + if (x == 0 || x < 0) { + return 0; + } + + // Get the next element like the formula provided + double next = 0.5 * (p + x/p); + + // Decide whether to go further + if (fabs(next - p) < DBL_EPSILON) { + return next; + } + + // Recusrevely try the next element in the series + return sqrt_rec(x, next); +} + +int main() { + printf("%f\n", sqrt_rec(2, 1)); + printf("%f\n", sqrt_rec(4, 1)); + printf("%f\n", sqrt_rec(8, 1)); + printf("%f\n", sqrt_rec(9, 1)); +} + diff --git a/S1/GdCP/klausur_c_1/sqrtrec.o b/S1/GdCP/klausur_c_1/sqrtrec.o new file mode 100644 index 0000000..b6ce4cc Binary files /dev/null and b/S1/GdCP/klausur_c_1/sqrtrec.o differ diff --git a/S1/GdCP/klausur_c_1/strmatch.c b/S1/GdCP/klausur_c_1/strmatch.c new file mode 100644 index 0000000..255ac8c --- /dev/null +++ b/S1/GdCP/klausur_c_1/strmatch.c @@ -0,0 +1,46 @@ +#include +#include + +int str_match(const char s[], const char p[], int strict) { + // takes string and pattern and strict flag + // should return if the characters in the pattern appear in the string in the same order + // strict should also check for difference in capital letters + // it does not matter whether there are characters in between (other) + + int ls = strlen(s); + int lp = strlen(p); + int o = -1; + + // Loop the patterns and the string for each pattern + for (const char *cp = p; *p != '\0'; p++) { + for (int j = 0; j < ls; j++) { + char chp = *p; + char cha = s[j]; + + if (!strict) { + chp = (char) tolower(chp); cha = (char) tolower(cha); + } + if (cha == chp) { + // Break condition + if (j < o) { + return 0; + } + + // Set the new occurence + o = j; + break; + } + } + } + return 1; +} + +#include + +int main() { + printf("%d\n", str_match("Hallo Welt", "alo", 1)); + printf("%d\n", str_match("Hallo Welt", "alo", 0)); + printf("%d\n", str_match("Hallo Welt", "alho", 1)); + printf("%d\n", str_match("Hallo Welt", "alho", 0)); +} + diff --git a/S1/GdCP/klausur_c_1/strmatch.o b/S1/GdCP/klausur_c_1/strmatch.o new file mode 100644 index 0000000..9b7f1a2 Binary files /dev/null and b/S1/GdCP/klausur_c_1/strmatch.o differ diff --git a/S1/GdCP/link.h b/S1/GdCP/link.h new file mode 100644 index 0000000..0307fa5 --- /dev/null +++ b/S1/GdCP/link.h @@ -0,0 +1,6 @@ +void prints(char *s); + +int main() { + prints("HELLO"); + +} diff --git a/S1/GdCP/matrix.c b/S1/GdCP/matrix.c new file mode 100644 index 0000000..2c97a7e --- /dev/null +++ b/S1/GdCP/matrix.c @@ -0,0 +1,50 @@ +#include +#define N 20 +void print(int m[N][N], int a, int b) { + for (int i = 0; i < a; i++) { + for (int j = 0; j < b - 1; j++) { + printf("%d ", m[i][j]); + } + printf("%d\n", m[i][b-1]); + } + +} +int main() { + int m1[N][N], m = 0, n = 0; + int m2[N][N], o = 0, p = 0; + int m3[N][N]; + + scanf("%d %d", &n, &m); + if (m > 20 || n > 20) return 1; + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + scanf("%d", &m1[i][j]); + } + } + scanf("%d %d", &p, &o); + if (o > 20 || p > 20 || n != o) return 1; + for (int i = 0; i < o; i++) { + for (int j = 0; j < p; j++) { + scanf("%d", &m2[i][j]); + } + } + + for (int i = 0; i < m; i++) { + for (int j = 0; j < p; j++) { + int res = 0; + for (int k = 0; k < n; k++) { + res += m1[i][k] * m2[k][j]; + } + m3[i][j] = res; + } + } + + + + + + print(m3, m, p); + + + +} diff --git a/S1/GdCP/pixel.c b/S1/GdCP/pixel.c new file mode 100644 index 0000000..9002001 --- /dev/null +++ b/S1/GdCP/pixel.c @@ -0,0 +1,258 @@ +#include +#include +#include +#include + +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 600 +#define NUM_PARTICLES 200 +#define NUM_TYPES 2 +#define FORCE_SCALE 100.0 +#define PARTICLE_RADIUS 5 +#define GRID_SIZE 50 // Spatial grid size + +typedef struct Particle { + float x, y; // Position + float vx, vy; // Velocity + int type; // Particle type (0, 1, 2... NUM_TYPES-1) + struct Particle *next; // Linked list pointer for spatial grid +} Particle; + +typedef struct { + int x, y; // Top-left corner of slider + int width, height; + float *value; // Pointer to the value it modifies +} Slider; + +Particle particles[NUM_PARTICLES]; +float force_matrix[NUM_TYPES][NUM_TYPES]; +Slider sliders[NUM_TYPES * NUM_TYPES]; +int grid_cols, grid_rows; +Particle **grid = NULL; // Dynamic grid allocation + +void init_particles() { + srand((unsigned int)time(NULL)); + for (int i = 0; i < NUM_PARTICLES; i++) { + particles[i].x = rand() % SCREEN_WIDTH; + particles[i].y = rand() % SCREEN_HEIGHT; + particles[i].vx = (rand() % 200 - 100) / 100.0f; + particles[i].vy = (rand() % 200 - 100) / 100.0f; + particles[i].type = rand() % NUM_TYPES; + particles[i].next = NULL; + } +} + +void init_force_matrix() { + for (int i = 0; i < NUM_TYPES; i++) { + for (int j = 0; j < NUM_TYPES; j++) { + force_matrix[i][j] = (rand() % 200 - 100) * FORCE_SCALE / 100.0f; + } + } +} + +void init_sliders() { + int slider_width = 100; + int slider_height = 10; + int spacing = 20; + int start_x = 10, start_y = SCREEN_HEIGHT - NUM_TYPES * spacing - 30; + + for (int i = 0; i < NUM_TYPES; i++) { + for (int j = 0; j < NUM_TYPES; j++) { + Slider *slider = &sliders[i * NUM_TYPES + j]; + slider->x = start_x + j * (slider_width + 5); + slider->y = start_y + i * spacing; + slider->width = slider_width; + slider->height = slider_height; + slider->value = &force_matrix[i][j]; + } + } +} + +void handle_sliders(SDL_Event *event) { + if (event->type == SDL_MOUSEBUTTONDOWN || event->type == SDL_MOUSEMOTION) { + int mx, my; + Uint32 buttons = SDL_GetMouseState(&mx, &my); + if (buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) { + for (int i = 0; i < NUM_TYPES * NUM_TYPES; i++) { + Slider *slider = &sliders[i]; + if (mx >= slider->x && mx <= slider->x + slider->width && + my >= slider->y && my <= slider->y + slider->height) { + float new_value = (float)(mx - slider->x) / slider->width * 2 - 1; + *slider->value = new_value * FORCE_SCALE; + } + } + } + } +} + +void update_particles(float dt) { + // Clear the grid + for (int i = 0; i < grid_cols * grid_rows; i++) { + grid[i] = NULL; + } + + // Assign particles to the grid + for (int i = 0; i < NUM_PARTICLES; i++) { + int gx = particles[i].x / GRID_SIZE; + int gy = particles[i].y / GRID_SIZE; + if (gx >= 0 && gx < grid_cols && gy >= 0 && gy < grid_rows) { + int cell_index = gy * grid_cols + gx; + particles[i].next = grid[cell_index]; + grid[cell_index] = &particles[i]; + } + } + + // Update particles + for (int i = 0; i < NUM_PARTICLES; i++) { + Particle *p = &particles[i]; + int gx = p->x / GRID_SIZE; + int gy = p->y / GRID_SIZE; + + float fx = 0, fy = 0; + + // Check surrounding grid cells + for (int dx = -1; dx <= 1; dx++) { + for (int dy = -1; dy <= 1; dy++) { + int ngx = gx + dx; + int ngy = gy + dy; + if (ngx >= 0 && ngx < grid_cols && ngy >= 0 && ngy < grid_rows) { + int cell_index = ngy * grid_cols + ngx; + Particle *neighbor = grid[cell_index]; + while (neighbor) { + if (neighbor != p) { + float dx = neighbor->x - p->x; + float dy = neighbor->y - p->y; + float dist2 = dx * dx + dy * dy; + if (dist2 > 0 && dist2 < 2500) { // Squared distance + float force = + force_matrix[p->type][neighbor->type] / sqrtf(dist2); + fx += force * dx; + fy += force * dy; + } + } + neighbor = neighbor->next; + } + } + } + } + + // Apply forces and update positions + p->vx += fx * dt; + p->vy += fy * dt; + p->x += p->vx * dt; + p->y += p->vy * dt; + + // Handle boundaries + if (p->x < 0 || p->x > SCREEN_WIDTH) + p->vx *= -1; + if (p->y < 0 || p->y > SCREEN_HEIGHT) + p->vy *= -1; + p->x = fmaxf(0, fminf(SCREEN_WIDTH, p->x)); + p->y = fmaxf(0, fminf(SCREEN_HEIGHT, p->y)); + } +} + +void render_particles(SDL_Renderer *renderer) { + for (int i = 0; i < NUM_PARTICLES; i++) { + Particle *p = &particles[i]; + switch (p->type) { + case 0: + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); + break; + case 1: + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); + break; + case 2: + SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); + break; + default: + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + break; + } + SDL_Rect rect = {(int)p->x - PARTICLE_RADIUS, (int)p->y - PARTICLE_RADIUS, + PARTICLE_RADIUS * 2, PARTICLE_RADIUS * 2}; + SDL_RenderFillRect(renderer, &rect); + } +} + +void render_sliders(SDL_Renderer *renderer) { + for (int i = 0; i < NUM_TYPES * NUM_TYPES; i++) { + Slider *slider = &sliders[i]; + SDL_SetRenderDrawColor(renderer, 200, 200, 200, 255); + SDL_Rect rect = {slider->x, slider->y, slider->width, slider->height}; + SDL_RenderFillRect(renderer, &rect); + + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); + int handle_x = + slider->x + ((*slider->value / FORCE_SCALE + 1) / 2) * slider->width; + SDL_Rect handle = {handle_x - 5, slider->y, 10, slider->height}; + SDL_RenderFillRect(renderer, &handle); + } +} + +int main(int argc, char *argv[]) { + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + SDL_Window *window = SDL_CreateWindow( + "Particle Simulator", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN); + if (!window) { + fprintf(stderr, "Could not create window: %s\n", SDL_GetError()); + SDL_Quit(); + return 1; + } + + SDL_Renderer *renderer = + SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + if (!renderer) { + fprintf(stderr, "Could not create renderer: %s\n", SDL_GetError()); + SDL_DestroyWindow(window); + SDL_Quit(); + return 1; + } + + // Initialize components + init_particles(); + init_force_matrix(); + init_sliders(); + + grid_cols = SCREEN_WIDTH / GRID_SIZE; + grid_rows = SCREEN_HEIGHT / GRID_SIZE; + grid = (Particle **)calloc(grid_cols * grid_rows, sizeof(Particle *)); + + int running = 1; + SDL_Event event; + Uint32 last_time = SDL_GetTicks(); + + while (running) { + while (SDL_PollEvent(&event)) { + if (event.type == SDL_QUIT) { + running = 0; + } else { + handle_sliders(&event); + } + } + + Uint32 current_time = SDL_GetTicks(); + float dt = (current_time - last_time) / 1000.0f; + last_time = current_time; + + update_particles(dt); + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + render_particles(renderer); + render_sliders(renderer); + SDL_RenderPresent(renderer); + } + + // Clean up + free(grid); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); + return 0; +} diff --git a/S1/GdCP/sms.c b/S1/GdCP/sms.c new file mode 100644 index 0000000..f0bce5e --- /dev/null +++ b/S1/GdCP/sms.c @@ -0,0 +1,22 @@ +#include +#include +#include + +int main() { + char s[161], m1[161], m2[161]; + int c1 = 0, c2 = 0; + + fgets(s, sizeof(s), stdin); + + for (int i = 0; i < strlen(s); i++) { + if (isalpha(s[i])) { + if (isupper(s[i])) { + m1[c1++] = s[i]; + } else m2[c2++] = s[i]; + } + + } + printf("Nachricht an Toni: %s\n", m1); + printf("Nachricht an Tomke: %s\n", m2); + +} diff --git a/S1/GdCP/square.c b/S1/GdCP/square.c new file mode 100644 index 0000000..750166d --- /dev/null +++ b/S1/GdCP/square.c @@ -0,0 +1,14 @@ +#include + +int main() { + int num, sum = 0; + scanf("%d", &num); + + while (num > 0) { + sum += num % 10; + num /= 10; + } + + printf("%d\n", sum); + return 0; +} diff --git a/S1/GdCP/test.c b/S1/GdCP/test.c new file mode 100644 index 0000000..42a81a8 --- /dev/null +++ b/S1/GdCP/test.c @@ -0,0 +1,7 @@ +d +th + + +sadfljsafl +sadfljsafl + diff --git a/S1/GdCP/testcprogram.c b/S1/GdCP/testcprogram.c new file mode 100644 index 0000000..1c3f907 --- /dev/null +++ b/S1/GdCP/testcprogram.c @@ -0,0 +1,41 @@ + +#include + +#include +#include +#define N 998 + +int *find_next(int *a) { + for (int i = 0; i < N; i++) if (a[i] != 0) return a + i; + return NULL; +} + +void kill_mults(int *a, int m) { + for (int i = 0; i < N; i++) if (a[i] % m == 0) a[i] = 0; +} + +int main() { + // Setup all numbers + int n[N], *c; + int p[N], r = 0; + for (int i = 0; i < N; i++) { + n[i] = i + 2; + } + + while (1){ + int *c = find_next(n); + if ((c = find_next()) == NULL) break; + p[r++] = *c; + kill_mults(n, *c); + } + + + for (int i = 0; i < r; i++) { + printf("%d ", p[i]); + + } + +} + + + diff --git a/S2/AnaMech/.unicourse b/S2/AnaMech/.unicourse new file mode 100644 index 0000000..155d802 --- /dev/null +++ b/S2/AnaMech/.unicourse @@ -0,0 +1,2 @@ +name: Analytische Mechanik +short: AnMe diff --git a/S2/AnaMech/AMechVL1.typ b/S2/AnaMech/MechVL1.typ similarity index 99% rename from S2/AnaMech/AMechVL1.typ rename to S2/AnaMech/MechVL1.typ index 385745c..f0ea1b4 100644 --- a/S2/AnaMech/AMechVL1.typ +++ b/S2/AnaMech/MechVL1.typ @@ -1,6 +1,6 @@ #import "./preamble.typ": * -#show: conf.with(num: 4) +#show: conf.with(num: 1) = Einleitung Newton < Lagrange < Hamilton diff --git a/S2/AnaMech/VL1-Bremene.typ b/S2/AnaMech/VL1-Bremene.typ deleted file mode 100644 index 7bc984b..0000000 --- a/S2/AnaMech/VL1-Bremene.typ +++ /dev/null @@ -1,85 +0,0 @@ -#import "./preamble.typ": * -#show: conf.with(num: 4) - -= Studienleistungen - -- mind. 2x vorrechnen - -= Integration - -#flashcard(0)[onw][ - sf -] - -Idee: - -- Differenzieren: -$ - F: I -> RR \ - F'(x) = lim_(x -> oo) -$ - -Die Idee ist nach einer Funktion zu fragen, welche die Vorschrift $F' = f$ erfuellt. - -Dazu kann in 2 Dimensionen der Flaecheninhalt unter dem Graphen der Funktion ermittelt werden. - -== Unbestimmte Integration - -Frage: - -Gegeben sei ein Intervall $I$ in RR und eine Funktion $f: I -> RR$ - -Finden wir $F: I -> RR$ mit $F' = f$? - -#definition[ - Gegeben: $I <= RR$ Intervall - - $F, f: I -> RR$ - - - $F$ eine Stammfunktion zu f auf I oder unbestimmtes -] - -Beachte: - -Gegeben seien Stammfunktionen $F_1, F_2$ zu $f$ - -$ - ==> (F_1 - F_2)'(x) = f(x) - f(x) = 0\ - ==> F_1 - F_2 "konstant auf" I -$ - -Man ueberprueft ob eine Funktion eine Stammfunktion ist anhand der Definition. - -Nicht jede Funktion hat eine Stammfunktion. - - -#theorem[ - Zwischenwertsatz fuer Ableitungen - - Sei $F: [a,b] -> RR$ diffb. - - $ - ==> F' "nimmt auf" (a,b) "jeden Wert zwischen" F'(a) "und" F'(b) "an". - $ -] - -#proof[ - // TODO: write this proof - -] - -Die Funktion, welche eine Stufenfunktion ist hat keine Stammfunktion, da sie im Widerspruch zu Satz @zws steht. - -#theorem[ - Summenregen fuer Integration - - Seien $I, I_0 "Intervalle in" RR$ uns $alpha_1, ... alpha_n in RR$ - - - Gegeben: - - $f_1, ...,f_n I -> RR $ - // TODO: zuende schreiben - -] - - diff --git a/S2/AnaMech/AMechVL1.pdf b/S2/AnaMech/pdfs/AMechVL1.pdf similarity index 99% rename from S2/AnaMech/AMechVL1.pdf rename to S2/AnaMech/pdfs/AMechVL1.pdf index c927465..6cbabec 100644 Binary files a/S2/AnaMech/AMechVL1.pdf and b/S2/AnaMech/pdfs/AMechVL1.pdf differ diff --git a/S2/AnaMech/AnaMech_Hahn_Penning_Zettel_1.pdf b/S2/AnaMech/pdfs/AnaMech_Hahn_Penning_Zettel_1.pdf similarity index 98% rename from S2/AnaMech/AnaMech_Hahn_Penning_Zettel_1.pdf rename to S2/AnaMech/pdfs/AnaMech_Hahn_Penning_Zettel_1.pdf index e514c1d..f961999 100644 Binary files a/S2/AnaMech/AnaMech_Hahn_Penning_Zettel_1.pdf and b/S2/AnaMech/pdfs/AnaMech_Hahn_Penning_Zettel_1.pdf differ diff --git a/S2/AnaMech/UebungHA1.pdf b/S2/AnaMech/pdfs/UebungHA1.pdf similarity index 100% rename from S2/AnaMech/UebungHA1.pdf rename to S2/AnaMech/pdfs/UebungHA1.pdf diff --git a/S2/AnaMech/template.typ b/S2/AnaMech/template.typ new file mode 100644 index 0000000..1342ba8 --- /dev/null +++ b/S2/AnaMech/template.typ @@ -0,0 +1,6 @@ +#import "./preamble.typ": * + +#show: conf.with(num: 1) + += Uebersicht + diff --git a/S2/CWR/.unicourse b/S2/CWR/.unicourse new file mode 100644 index 0000000..cf082aa --- /dev/null +++ b/S2/CWR/.unicourse @@ -0,0 +1,2 @@ +name: Computerwissenschaftliches Rechnen +short: Cwr diff --git a/S2/CWR/CWRVL1.pdf b/S2/CWR/CWRVL1.pdf deleted file mode 100644 index 49d0cc6..0000000 Binary files a/S2/CWR/CWRVL1.pdf and /dev/null differ diff --git a/S2/CWR/CWRVL1.typ b/S2/CWR/CwrVL1.typ similarity index 100% rename from S2/CWR/CWRVL1.typ rename to S2/CWR/CwrVL1.typ diff --git a/S2/CWR/pdfs/template.pdf b/S2/CWR/pdfs/template.pdf new file mode 100644 index 0000000..8218ba0 Binary files /dev/null and b/S2/CWR/pdfs/template.pdf differ diff --git a/S2/CWR/template.typ b/S2/CWR/template.typ new file mode 100644 index 0000000..6feab29 --- /dev/null +++ b/S2/CWR/template.typ @@ -0,0 +1,3 @@ + += Uebersicht + diff --git a/S2/DiffII/.unicourse b/S2/DiffII/.unicourse new file mode 100644 index 0000000..189c43c --- /dev/null +++ b/S2/DiffII/.unicourse @@ -0,0 +1,2 @@ +name: Diff II +short: DiII diff --git a/S2/DiffII/VL/DiffVL1.typ b/S2/DiffII/VL/DiIIVL1.typ similarity index 100% rename from S2/DiffII/VL/DiffVL1.typ rename to S2/DiffII/VL/DiIIVL1.typ diff --git a/S2/DiffII/VL/DiIIVL2.typ b/S2/DiffII/VL/DiIIVL2.typ new file mode 100644 index 0000000..d9cf102 --- /dev/null +++ b/S2/DiffII/VL/DiIIVL2.typ @@ -0,0 +1,3 @@ + += Uebersicht bla + diff --git a/S2/DiffII/VL/DiIIVL3.typ b/S2/DiffII/VL/DiIIVL3.typ new file mode 100644 index 0000000..1342ba8 --- /dev/null +++ b/S2/DiffII/VL/DiIIVL3.typ @@ -0,0 +1,6 @@ +#import "./preamble.typ": * + +#show: conf.with(num: 1) + += Uebersicht + diff --git a/S2/DiffII/VL/DiIIVL4.typ b/S2/DiffII/VL/DiIIVL4.typ new file mode 100644 index 0000000..6625b7a --- /dev/null +++ b/S2/DiffII/VL/DiIIVL4.typ @@ -0,0 +1,5 @@ +// Diff template + + += Uebersicht + diff --git a/S2/DiffII/VL/DiffVL1.pdf b/S2/DiffII/VL/DiffVL1.pdf deleted file mode 100644 index d555df7..0000000 Binary files a/S2/DiffII/VL/DiffVL1.pdf and /dev/null differ diff --git a/S2/DiffII/pdfs/DiIIVL2.pdf b/S2/DiffII/pdfs/DiIIVL2.pdf new file mode 100644 index 0000000..78d6f0b Binary files /dev/null and b/S2/DiffII/pdfs/DiIIVL2.pdf differ diff --git a/S2/DiffII/pdfs/DiIIVL4.pdf b/S2/DiffII/pdfs/DiIIVL4.pdf new file mode 100644 index 0000000..22c3b37 Binary files /dev/null and b/S2/DiffII/pdfs/DiIIVL4.pdf differ diff --git a/S2/DiffII/template.typ b/S2/DiffII/template.typ new file mode 100644 index 0000000..9fcabbf --- /dev/null +++ b/S2/DiffII/template.typ @@ -0,0 +1,7 @@ +// Diff template +#import "./preamble.typ": * + +#show: conf.with(num: 1) + += Uebersicht + diff --git a/S2/ExPhyII/.unicourse b/S2/ExPhyII/.unicourse new file mode 100644 index 0000000..c3d1a80 --- /dev/null +++ b/S2/ExPhyII/.unicourse @@ -0,0 +1,2 @@ +name: Experimentalphysik II +short: ExII diff --git a/S2/ExPhyII/VL/ExVL1.typ b/S2/ExPhyII/ExIIVL1.typ similarity index 100% rename from S2/ExPhyII/VL/ExVL1.typ rename to S2/ExPhyII/ExIIVL1.typ diff --git a/S2/ExPhyII/VL/ExVL1.pdf b/S2/ExPhyII/VL/ExVL1.pdf deleted file mode 100644 index c213ebc..0000000 Binary files a/S2/ExPhyII/VL/ExVL1.pdf and /dev/null differ diff --git a/S2/ExPhyII/template.typ b/S2/ExPhyII/template.typ new file mode 100644 index 0000000..1342ba8 --- /dev/null +++ b/S2/ExPhyII/template.typ @@ -0,0 +1,6 @@ +#import "./preamble.typ": * + +#show: conf.with(num: 1) + += Uebersicht + diff --git a/S2/Neuro/.unicourse b/S2/Neuro/.unicourse new file mode 100644 index 0000000..d873319 --- /dev/null +++ b/S2/Neuro/.unicourse @@ -0,0 +1,2 @@ +name: Computational Neuroscience +short: Neuro diff --git a/S2/Neuro/NeuroVL1.typ b/S2/Neuro/NeuroVL1.typ new file mode 100644 index 0000000..e69de29 diff --git a/S2/Neuro/VL/NeuroVL1.typ b/S2/Neuro/VL/NeuroVL1.typ new file mode 100644 index 0000000..1342ba8 --- /dev/null +++ b/S2/Neuro/VL/NeuroVL1.typ @@ -0,0 +1,6 @@ +#import "./preamble.typ": * + +#show: conf.with(num: 1) + += Uebersicht + diff --git a/S2/Neuro/template.typ b/S2/Neuro/template.typ new file mode 100644 index 0000000..1342ba8 --- /dev/null +++ b/S2/Neuro/template.typ @@ -0,0 +1,6 @@ +#import "./preamble.typ": * + +#show: conf.with(num: 1) + += Uebersicht + diff --git a/S2/Praktikum/Vorbesprechung.pdf b/S2/Praktikum/Vorbesprechung.pdf deleted file mode 100644 index 4254c2d..0000000 Binary files a/S2/Praktikum/Vorbesprechung.pdf and /dev/null differ diff --git a/S2/Praktikum/Vorbesprechung.typ b/S2/Praktikum/Vorbesprechung.typ deleted file mode 100644 index 7b69a44..0000000 --- a/S2/Praktikum/Vorbesprechung.typ +++ /dev/null @@ -1,3 +0,0 @@ -= Einleitung - -Folien sind auf StudIP verfuegbar. diff --git a/S2/Stundenplan.png b/S2/Stundenplan.png deleted file mode 100644 index 75ebfa1..0000000 Binary files a/S2/Stundenplan.png and /dev/null differ diff --git a/S2/links.md b/S2/links.md deleted file mode 100644 index 5ebf77b..0000000 --- a/S2/links.md +++ /dev/null @@ -1,8 +0,0 @@ -# Links -ExPhy Uebung Di 16-18 NR 7: -https://ecampus.uni-goettingen.de/h1/pages/cs/sys/portal/hisinoneIframePage.faces?id=studip&navigationPosition=link_studip&url=https%3A%2F%2Fstudip-ecampus.uni-goettingen.de%2Findex.php%3Fsso%3Dcasgoe%26cancel_login%3D1%26again%3Dyes%26redirect_to%3Dhttps%253A%252F%252Fstudip-ecampus.uni-goettingen.de%252Fdispatch.php%252Fmy_courses%26redirect_token%3D947a61f0a9df959879bce689abac0ffa - - -# Other modules -Zusammenhang Mensch und Natur; Modul B.Phy.1609 - diff --git a/S3/links.md b/S3/links.md new file mode 100644 index 0000000..37b9405 --- /dev/null +++ b/S3/links.md @@ -0,0 +1,3 @@ +# Links + +Preparation for the third semester links diff --git a/courses.txt b/misc/courses.txt similarity index 100% rename from courses.txt rename to misc/courses.txt diff --git a/pdfs/template.pdf b/pdfs/template.pdf new file mode 100644 index 0000000..51aa9eb Binary files /dev/null and b/pdfs/template.pdf differ diff --git a/preamble.typ b/preamble.typ new file mode 100644 index 0000000..c76cd55 --- /dev/null +++ b/preamble.typ @@ -0,0 +1,14 @@ +#import "./default.typ": * + +#let conf(num: none, ueb: false, body) = { + // Global settings + show: default + + // Set the header + [Testing Preamble] + // Make tcahe outline + outline() + + // load the document + body +} diff --git a/template.typ b/template.typ index aabec9e..1342ba8 100644 --- a/template.typ +++ b/template.typ @@ -4,5 +4,3 @@ = Uebersicht - -