1. Си / Говнокод #29055

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    int IsEven(long long int number){
    	if (number == 0) return 0; 
    	long long int loc_num = 0;
    	update: 
    	
    	if (number == loc_num+1) {return 1;
    	} else if (number == (loc_num+1)*(-1)) { return 1;
    	} else {
    		if (number == loc_num+2) {return 0;
    		} else if (number == (loc_num+2)*(-1)) { return 0;
    		} else {
    			if (number == loc_num+3) {return 1;
    			} else if (number == (loc_num+3)*(-1)) { return 1;
    			} else {
    				if (number == loc_num+4) {return 0;
    				} else if (number == (loc_num+4)*(-1)) { return 0;
    				} else {
    					if (number == loc_num+5) {return 1;
    					} else if (number == (loc_num+5)*(-1)) { return 1;
    					} else {
    						if (number == loc_num+6) {return 0;
    						} else if (number == (loc_num+6)*(-1)) { return 0;
    						} else {
    							if (number == loc_num+7) {return 1;
    							} else if (number == (loc_num+7)*(-1)) { return 1;
    							} else {
    								if (number == loc_num+8) {return 0;
    								} else if (number == (loc_num+8)*(-1)) { return 0;
    								} else {
    									if (number == loc_num+9) {return 1;
    									} else if (number == (loc_num+9)*(-1)) { return 1;
    									} else {
    										if (number == loc_num+10) {return 0;
    										} else if (number == (loc_num+10)*(-1)) { return 0;
    										} else {
    												loc_num+=10; 
    												goto update;
    											}
    										}
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    	}

    TurboLyudoed, 14 Ноября 2024

    Комментарии (3)
  2. C++ / Говнокод #29054

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    xxx: Теперь сделайте так, чтобы цифры выводились следующим образом (используя программу из предыдущего задания):
                1
             2 1
          3 2 1
       4 3 2 1
    5 4 3 2 1
    
    yyy:
    
    #include <print>
    
    inline constexpr std::size_t kSize = 5;
    
    template <std::size_t N, std::size_t NN>
    constexpr auto operator+(const std::array<char, N>& first, const std::array<char, NN>& second) -> std::array<char, N + NN> {
      std::array<char, N + NN> response;  // NOLINT
      std::ranges::copy(first, response.begin());
      std::ranges::copy(second, response.begin() + first.size());
      return response;
    };
    
    auto main() -> int {
      []<std::size_t... Is>(std::index_sequence<Is...>) {
        // clang-format off
        ([&]<std::size_t... IIs, std::size_t... IIIs>(std::index_sequence<IIs...>, std::index_sequence<IIIs...>) {
          constexpr std::format_string<decltype(IIs)...> fmt = [] {
            static constexpr auto response = ((std::ignore = IIIs, std::array{' ', ' '}) + ... + ((std::ignore = IIs, std::array{'{', '}', ' '}) + ... + std::array{'\0'}));
            return response.begin();
          }();
          constexpr auto v = Is;
          std::println(fmt, (v - IIs + 1)...);
        }(std::make_index_sequence<Is + 1>(), std::make_index_sequence<kSize - Is - 1>()), ...);
        // clang-format on
      }(std::make_index_sequence<kSize>());
    };

    Fluttie, 07 Ноября 2024

    Комментарии (1)
  3. Куча / Говнокод #29053

    0

    1. 1
    Бесконечный оффтоп имени Гологуба #2

    #1: https://govnokod.ru/28992 https://govnokod.xyz/_28992

    nepeKamHblu_nemyx, 05 Ноября 2024

    Комментарии (423)
  4. Куча / Говнокод #29052

    0

    1. 1
    Пиздец-оффтоп #105

    #75: https://govnokod.ru/28705 https://govnokod.xyz/_28705
    #76: https://govnokod.ru/28712 https://govnokod.xyz/_28712
    #77: https://govnokod.ru/28722 https://govnokod.xyz/_28722
    #78: https://govnokod.ru/28730 https://govnokod.xyz/_28730
    #79: https://govnokod.ru/28736 https://govnokod.xyz/_28736
    #80: https://govnokod.ru/28740 https://govnokod.xyz/_28740
    #81: https://govnokod.ru/28750 https://govnokod.xyz/_28750
    #82: https://govnokod.ru/28779 https://govnokod.xyz/_28779
    #83: https://govnokod.ru/28788 https://govnokod.xyz/_28788
    #84: https://govnokod.ru/28795 https://govnokod.xyz/_28795
    #85: https://govnokod.ru/28808 https://govnokod.xyz/_28808
    #86: (vanished) https://govnokod.xyz/_28814
    #87: https://govnokod.ru/28817 https://govnokod.xyz/_28817
    #88: https://govnokod.ru/28836 https://govnokod.xyz/_28836
    #89: https://govnokod.ru/28843 https://govnokod.xyz/_28843
    #90: https://govnokod.ru/28874 https://govnokod.xyz/_28874
    #91: https://govnokod.ru/28880 https://govnokod.xyz/_28880
    #92: https://govnokod.ru/28884 https://govnokod.xyz/_28884
    #93: https://govnokod.ru/28889 https://govnokod.xyz/_28889
    #94: https://govnokod.ru/28895 https://govnokod.xyz/_28895
    #95: https://govnokod.ru/28904 https://govnokod.xyz/_28904
    #96: https://govnokod.ru/28912 https://govnokod.xyz/_28912
    #97: https://govnokod.ru/28918 https://govnokod.xyz/_28918
    #98: https://govnokod.ru/28932 https://govnokod.xyz/_28932
    #99: https://govnokod.ru/28936 https://govnokod.xyz/_28936
    #100: https://govnokod.ru/28940 https://govnokod.xyz/_28940
    #101: https://govnokod.ru/28949 https://govnokod.xyz/_28949
    #102: https://govnokod.ru/28978 https://govnokod.xyz/_28978
    #103: https://govnokod.ru/28982 https://govnokod.xyz/_28982
    #104: https://govnokod.ru/28989 https://govnokod.xyz/_28989

    nepeKamHblu_nemyx, 04 Ноября 2024

    Комментарии (407)
  5. Куча / Говнокод #29003

    0

    1. 1
    Питушня #41

    #11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
    #12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
    #13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
    #14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
    #15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
    #16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
    #17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
    #18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
    #19: https://govnokod.ru/27620 https://govnokod.xyz/_27620
    #20: https://govnokod.ru/27816 https://govnokod.xyz/_27816
    #21: https://govnokod.ru/27956 https://govnokod.xyz/_27956
    #22: https://govnokod.ru/28143 https://govnokod.xyz/_28143
    #23: https://govnokod.ru/28315 https://govnokod.xyz/_28315
    #24: (vanished) https://govnokod.xyz/_28362
    #25: (vanished) https://govnokod.xyz/_28463
    #26: https://govnokod.ru/28481 https://govnokod.xyz/_28481
    #27: https://govnokod.ru/28537 https://govnokod.xyz/_28537
    #28: https://govnokod.ru/28619 https://govnokod.xyz/_28619
    #29: (vanished) https://govnokod.xyz/_28663
    #30: https://govnokod.ru/28673 https://govnokod.xyz/_28673
    #31: https://govnokod.ru/28679 https://govnokod.xyz/_28679
    #32: https://govnokod.ru/28687 https://govnokod.xyz/_28687
    #33: https://govnokod.ru/28694 https://govnokod.xyz/_28694
    #34: https://govnokod.ru/28701 https://govnokod.xyz/_28701
    #35: https://govnokod.ru/28707 https://govnokod.xyz/_28707
    #36: https://govnokod.ru/28714 https://govnokod.xyz/_28714
    #37: https://govnokod.ru/28724 https://govnokod.xyz/_28724
    #38: https://govnokod.ru/28732 https://govnokod.xyz/_28732
    #39: https://govnokod.ru/28839 https://govnokod.xyz/_28839
    #40: https://govnokod.ru/28909 https://govnokod.xyz/_28909

    nepeKamHblu_nemyx, 23 Октября 2024

    Комментарии (211)
  6. Куча / Говнокод #29002

    0

    1. 1
    IT Оффтоп #207

    #177: https://govnokod.ru/28709 https://govnokod.xyz/_28709
    #178: https://govnokod.ru/28716 https://govnokod.xyz/_28716
    #179: https://govnokod.ru/28726 https://govnokod.xyz/_28726
    #180: https://govnokod.ru/28734 https://govnokod.xyz/_28734
    #181: https://govnokod.ru/28739 https://govnokod.xyz/_28739
    #182: https://govnokod.ru/28749 https://govnokod.xyz/_28749
    #183: https://govnokod.ru/28777 https://govnokod.xyz/_28777
    #184: https://govnokod.ru/28790 https://govnokod.xyz/_28790
    #185: https://govnokod.ru/28794 https://govnokod.xyz/_28794
    #186: https://govnokod.ru/28815 https://govnokod.xyz/_28815
    #187: https://govnokod.ru/28833 https://govnokod.xyz/_28833
    #188: https://govnokod.ru/28837 https://govnokod.xyz/_28837
    #189: https://govnokod.ru/28840 https://govnokod.xyz/_28840
    #190: https://govnokod.ru/28875 https://govnokod.xyz/_28875
    #191: https://govnokod.ru/28878 https://govnokod.xyz/_28878
    #192: https://govnokod.ru/28886 https://govnokod.xyz/_28886
    #193: https://govnokod.ru/28911 https://govnokod.xyz/_28911
    #194: https://govnokod.ru/28914 https://govnokod.xyz/_28914
    #195: https://govnokod.ru/28917 https://govnokod.xyz/_28917
    #196: https://govnokod.ru/28925 https://govnokod.xyz/_28925
    #197: https://govnokod.ru/28935 https://govnokod.xyz/_28935
    #198: https://govnokod.ru/28938 https://govnokod.xyz/_28938
    #199: https://govnokod.ru/28942 https://govnokod.xyz/_28942
    #200: https://govnokod.ru/28945 https://govnokod.xyz/_28945
    #201: https://govnokod.ru/28948 https://govnokod.xyz/_28948
    #202: https://govnokod.ru/28951 https://govnokod.xyz/_28951
    #203: https://govnokod.ru/28954 https://govnokod.xyz/_28954
    #204: https://govnokod.ru/28971 https://govnokod.xyz/_28971
    #205: https://govnokod.ru/28986 https://govnokod.xyz/_28986
    #206: https://govnokod.ru/28991 https://govnokod.xyz/_28991

    nepeKamHblu_nemyx, 22 Октября 2024

    Комментарии (421)
  7. Си / Говнокод #29001

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    // https://github.com/micropython/micropython/blob/1b89c503db690967d50699abe0bfa942f6f6b15e/ports/qemu/mcu/rv32/interrupts.c#L131
    
    const char *lookup_cause(uint32_t mcause) {
        if (mcause & 0x80000000) {
            switch (mcause & 0x7FFFFFFF) {
                case 1:
                    return exception_causes[1];
                case 3:
                    return exception_causes[2];
                case 5:
                    return exception_causes[3];
                case 7:
                    return exception_causes[4];
                case 9:
                    return exception_causes[5];
                case 11:
                    return exception_causes[6];
                default:
                    return (mcause >= 16) ?
                           exception_causes[7] :
                           exception_causes[0];
            }
        }
    
        switch (mcause) {
            case 0:
                return exception_causes[8];
            case 1:
                return exception_causes[9];
            case 2:
                return exception_causes[10];
            case 3:
                return exception_causes[11];
            case 4:
                return exception_causes[12];
            case 5:
                return exception_causes[13];
            case 6:
                return exception_causes[14];
            case 7:
                return exception_causes[15];
            case 8:
                return exception_causes[16];
            case 9:
                return exception_causes[17];
            case 11:
                return exception_causes[18];
            case 12:
                return exception_causes[19];
            case 13:
                return exception_causes[20];
            case 15:
                return exception_causes[21];
            default: {
                if ((mcause >= 24 && mcause <= 31) ||
                    (mcause >= 48 && mcause <= 63)) {
                    return exception_causes[22];
                }
    
                return exception_causes[0];
            }
        }
    }

    Микропитухон

    j123123, 18 Октября 2024

    Комментарии (4)
  8. PHP / Говнокод #29000

    0

    1. 1
    $_GET

    OCETuHCKuu_nemyx, 15 Октября 2024

    Комментарии (22)
  9. C++ / Говнокод #28999

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    template <typename T, typename... Ts>
    struct StructureChain : T, StructureChain<Ts...>
    {
    	StructureChain(const T &t, const Ts&... a) : T(t), StructureChain<Ts...>(a...)
    	{
    		((T*)this)->pNext = (StructureChain<Ts...>*)this;
    	}
    };
    
    template <typename T>
    struct StructureChain<T> : T
    {
    	StructureChain(const T &t) : T(t){}
    };
    
    // Positional arguments? Im my C++?  It's more likely than you think!
    template<typename T>
    struct SetterFunc;
    template<typename T, typename V>
    struct SetterVal
    {
    	const SetterFunc<T> &func;
    	const V &val;
    	SetterVal(const SetterFunc<T> &f, const V &v) : func(f), val(v){}
    };
    template<typename T>
    struct SetterFunc
    {
    	const T &func;
    	SetterFunc(const T &data)
    		: func(data)
    	{}
    	template <typename V>
    	SetterVal<T,V> operator() (const V &v) {return SetterVal(*this,v);}
    	template <typename V>
    	SetterVal<T,V> operator= (const V &v) {return SetterVal(*this,v);}
    };
    
    template <typename T, typename... Ts>
    void FillStructure(T &t, const Ts&... ts)
    {
    	auto filler = [](T &t, const auto &arg){
    		auto T::*ptr = arg.func.func(t);
    		t.*ptr = arg.val;
    	};
    	(filler(t,ts),...);
    }
    // todo: remove extra unused copy
    #define $(k) SetterFunc([](auto a){return &decltype(a)::k;})
    
    template <typename T, typename... Ts>
    T $M(T t, const Ts&... ts)
    {
    	FillStructure(t, ts...);
    	return t;
    }
    // ...
    		VkSubresourceLayout layout = {0};
    		layout.rowPitch = pitch1;
    
    		StructureChain iinfo{
    			$M(VkImageCreateInfo{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO},
    			   $(imageType) = VK_IMAGE_TYPE_2D,
    			   $(format) = p010?VK_FORMAT_R16_UNORM:VK_FORMAT_R8_UNORM,
    			   $(extent) = VkExtent3D{ WIDTH, HEIGHT, 1 },
    			   $(mipLevels) = 1,
    			   $(arrayLayers)= 1,
    			   $(samples) =VK_SAMPLE_COUNT_1_BIT,
    			   $(tiling) = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT,
    			   $(usage) = VK_IMAGE_USAGE_STORAGE_BIT,
    			   $(sharingMode) = VK_SHARING_MODE_EXCLUSIVE
    			   ),
    			$M(VkExternalMemoryImageCreateInfo{VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO},
    			   $(handleTypes) = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT
    			   ),
    			$M(VkImageDrmFormatModifierExplicitCreateInfoEXT{VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT},
    			   $(drmFormatModifierPlaneCount) = 1,
    			   $(drmFormatModifier) =  mod,
    			   $(pPlaneLayouts) = &layout
    			)
    		};
    		VK_CHECK_RESULT(vkCreateImage(dev.device, &iinfo, NULL, &texture0.image)); // create image.

    Positional arguments? Im my C++? It's more likely than you think!

    mittorn, 15 Октября 2024

    Комментарии (2)
  10. Си / Говнокод #28998

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    int iseven(long long int number)
    {
    	struct Num {
    		unsigned int x:1;
    		unsigned int y:31;
    		unsigned int z:32;
    	} num = (*(struct Num*)(&number));
    	return num.x; //Если результат 1, то нечётное.
    }

    Функция определения чётности числа посредством возврата младшего бита.

    TurboLyudoed, 11 Октября 2024

    Комментарии (6)