1. Java / Говнокод #24635

    −3

    1. 1
    System.out.println("The result of " + calc.getFirstNo() + " " + calc.getCharacter() + " " + calc.getSecondNo() + " is " + calc.calculate(calc.getFirstNo(), calc.getCharacter(), calc.getSecondNo()));

    shite, 19 Августа 2018

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

    −2

    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
    83. 83
    /*
    	Программа для генерации и вывода разряженной матрицы
    	Специально для сайта govnokod.ru
    */
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    
    // Объявление переменных
    const int first_index_size=20;
    const int second_index_size=50;
    char matrix_array[first_index_size][second_index_size];
    
    enum border_style{
    	line,single 
    };
    
    void borders(border_style matrix_border)
    {
    	switch(matrix_border)
    	{
    		case 0:
    			for(int i=0; i<(second_index_size+2); i++)
    				std::cout<<"#";
    			std::cout<<"\n";
    			break;
    		case 1:
    			std::cout<<"#";
    	}
    }
    
    void rand_func_init()
    {
    	// Инициализация функции rand()
    	srand(time(0));
    	rand();
    }
    
    void matrix_init_zero()
    {
    	// Инициализация матрицы нулём	
    	for(int i=0; i<first_index_size; i++)
    		for(int t=0; t<second_index_size; t++)
    			matrix_array[i][t]=0;
    }
    
    void matrix_init_rand()
    {
    	// Заполнение матрицы
    	for(int i=0; i<first_index_size; i++)
    	{
    		int init_num=rand()%11;
    		while(init_num)
    		{
    			init_num--;
    			matrix_array[i][rand()%50]=149;
    		}
    	}
    }
    
    void matrix_print()
    {
    	// Вывод матрицы	
    	borders(line);
    	for(int i=0; i<first_index_size; i++)
    	{
    		borders(single);
    		for(int t=0; t<second_index_size; t++)	
    			std::cout<<matrix_array[i][t];
    		borders(single);
    		std::cout<<"\n";
    	}
    	borders(line);
    }
    
    int main()
    {
    	rand_func_init();
    	matrix_init_zero();
    	matrix_init_rand();
    	matrix_print();
    	return 0;
    }

    Разряженная матрица 20x50.
    Количество ненулевых значений от 0 до 10.

    BelCodeMonkey, 18 Августа 2018

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

    +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
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    #include <iostream>
    #include <type_traits>
    #include <utility>
    #include <array>
    
    template<size_t Size, typename T, typename FunctorType, size_t... idx>
    constexpr std::array<decltype(std::declval<FunctorType>().operator()(std::declval<T>())), Size>
                  map_impl(const std::array<T, Size> & arr, FunctorType && f, std::index_sequence<idx...>)
    {
        return std::array{ f(std::get<idx>(arr))... };
    }
    
    template<size_t Size, typename T, typename FunctorType>
    constexpr std::array<decltype(std::declval<FunctorType>().operator()(std::declval<T>())), Size>
                  map(const std::array<T, Size> & arr, FunctorType && f)
    {
        return map_impl(arr, f, std::make_index_sequence<Size>{});
    }
    
    struct MyFunctor {
        constexpr float operator()(int arg)
        {
            return static_cast<float>(arg * arg) / 2.0f;
        }
    };
    
    int main()
    {
        constexpr std::array arr{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    
        auto arrMappedFunctor = map(arr, MyFunctor{});
        auto arrMappedLambda = map(arr, [](int x) constexpr { return static_cast<float>(x * x) / 2.0f; });
    
        for (auto && x : arrMappedFunctor) {
            std::cout << x << ' ';
        }
        std::cout << std::endl;
        for (auto && x : arrMappedLambda ) {
            std::cout << x << ' ';
        }
        std::cout << std::endl;
        return 0;
    }

    0.5 2 4.5 8 12.5 18 24.5 32 40.5 50
    0.5 2 4.5 8 12.5 18 24.5 32 40.5 50


    Метушня выходит на новый уровень: полноценный map в compile-time. Поддерживает как ручные функторы с перегруженным operator(), так и constexpr-лямбды. При помощи небольшой модификации возможно реализовать поддержку кортежей с произвольными типами.

    gost, 18 Августа 2018

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

    +1

    1. 1
    Давайте течь от отступов и ругать код без оных.

    rotoeb, 17 Августа 2018

    Комментарии (20)
  5. JavaScript / Говнокод #24630

    −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
    const orbs = Object.keys(defaultOrbs).reduce((acc, el) => {
            const newAcc = {}
            Object.keys(defaultOrbs[el]).forEach((elk) => {
                if (newAcc[elk] == null) newAcc[elk] = { ...(acc[elk] || {})}
                newAcc[elk][el] = defaultOrbs[el][elk]
            })
            return newAcc
        }, {})
    
    invoke(orbs, mult) {
            if(this.props.onChange) {
                this.props.onChange(Object.keys(orbs).reduce((acc, el) => ({
                        ...acc,
                        [el]: Object.keys(orbs[el]).reduce((ack, elk) => ({
                            ...ack,
                            [elk]: orbs[el][elk] * mult 
                        }), {})
                    }), {}))
            }
        }

    Когда сишник лезет в джаваскрипт
    А кому-то в этом говне копаться и по пакетикам раскладывать

    wylde, 16 Августа 2018

    Комментарии (11)
  6. JavaScript / Говнокод #24629

    −1

    1. 1
    https://pikabu.ru/story/bez_lokha_i_zhizn_plokha_6096016

    minusinho, 16 Августа 2018

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

    0

    1. 1
    http://codeforces.com/blog/entry/61248

    guestinxo, 16 Августа 2018

    Комментарии (94)
  8. Си / Говнокод #24627

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    #include <stdio.h>
    #include <inttypes.h> 
    
    int main(void) {
    	float a = 0;
    	float b = -9.8 * 0;
    	uint32_t* pa = (void*)&a;
    	uint32_t* pb = (void*)&b;
    	printf("%li %li %i %f %f\n",pa[0] , pb[0], pb[0]>>31, b+0, b);
    	return 0;
    }

    Нолик со взведенным знаковым битом. Вот зачем он нужен?

    Psionic, 16 Августа 2018

    Комментарии (3)
  9. Python / Говнокод #24626

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    def lookup(self, code):
            """
            Looks up code in Redis
            Returns None on failure
            """
            url = self.redis.get(code)
            try:
                pass
            except:
                url = None
            return url

    Вот такое на полном серьезе получили как кусочек домашнего задания для соискателя на Senior Python Engineer

    Flid, 16 Августа 2018

    Комментарии (83)
  10. Куча / Говнокод #24625

    +2

    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
    /****************************************************************************
    **
    ** Copyright (C) 2015 The Qt Company Ltd.
    ** Contact: http://www.qt.io/licensing/
    **
    ** This file is part of the ActiveQt framework of the Qt Toolkit.
    **
    ** $QT_BEGIN_LICENSE:BSD$
    ** Commercial License Usage
    ** Licensees holding valid commercial Qt licenses may use this file in
    ** accordance with the commercial license agreement provided with the
    ** Software or, alternatively, in accordance with the terms contained in
    ** a written agreement between you and The Qt Company. For licensing terms
    ** and conditions see https://www.qt.io/terms-conditions. For further
    ** information use the contact form at https://www.qt.io/contact-us.
    **
    ** BSD License Usage
    ** Alternatively, you may use this file under the terms of the BSD license
    ** as follows:
    **
    ** "Redistribution and use in source and binary forms, with or without
    ** modification, are permitted provided that the following conditions are
    ** met:
    **   * Redistributions of source code must retain the above copyright
    **     notice, this list of conditions and the following disclaimer.
    **   * Redistributions in binary form must reproduce the above copyright
    **     notice, this list of conditions and the following disclaimer in
    **     the documentation and/or other materials provided with the
    **     distribution.
    **   * Neither the name of The Qt Company Ltd nor the names of its
    **     contributors may be used to endorse or promote products derived
    **     from this software without specific prior written permission.
    **
    **
    ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
    **
    ** $QT_END_LICENSE$
    **
    ****************************************************************************/

    Вот блин, почти в любом проекте в начале каждого файла такая вот куча . Я блядь открываю файл, чтобы посмотреть, что это, хотя бы одну строчку написали: этот класс занимается тем-то и тем-то, так нет, а вот всю эту бурду "ASS PISS" LSD LICENCE - пожалуйста.

    Steve_Brown, 15 Августа 2018

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