1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #27123

    +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
    ShipType Ship::getShipTypeByLength(int length)
    {
        switch (length) {
            case 1: return BOAT;
            case 2: return CRUISER;
            case 3: return DESTROYER;
            case 4: return BATTLESHIP;
            case 5: return AIRCRAFT_CARRIER;
    
            default:
                std::cout << "No ship meets the given length: " << length << std::endl;
                return ERROR_SHIP;
        }
    }
    
    int Ship::getShipLengthByType(ShipType type)
    {
        switch (type) {
            case BOAT: return 1;
            case CRUISER: return 2;
            case DESTROYER: return 3;
            case BATTLESHIP: return 4;
            case AIRCRAFT_CARRIER: return 5;
    
            default:
                std::cout << "No ship meets the given type: " << type << std::endl;
                return 0;
        }
    }
    
    int Ship::getShipAmountByType(ShipType type)
    {
        switch (type) {
            case BOAT: return 4;
            case CRUISER: return 3;
            case DESTROYER: return 2;
            case BATTLESHIP: return 1;
            case AIRCRAFT_CARRIER: return 1;
    
            default:
                std::cout << "No ship meets the given type: " << type << std::endl;
                return 0;
        }
    }
    
    Coordinates Ship::getFirstBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
    {
        Coordinates result;
        if (orientation == HORIZONTAL) {
            result.x = x - (length / 2);
            result.y = y;
        } else {
            result.x = x;
            result.y = y - (length / 2);
        }
        return result;
    }
    
    Coordinates Ship::getLastBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
    {
        Coordinates result;
        if (orientation == HORIZONTAL) {
            result.x = x + (length / 2) + (length % 2) - 1;
            result.y = y;
        } else {
            result.x = x;
            result.y = y + (length / 2) + (length % 2) - 1;
        }
        return result;
    }

    Вот некоторые полезные функции из игры «Морской Бой», которую я зачем-то написал.

    oaoaoammm, 21 Ноября 2020

    Комментарии (44)
  3. JavaScript / Говнокод #27038

    +2

    1. 1
    2. 2
    ARMv8.3-a adds a new instruction "jscvt", which can be used for converting double to int32_t in JS semantics.
    https://bugs.webkit.org/show_bug.cgi?id=184023#c24

    MAKAKA, 18 Октября 2020

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

    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
    ███████                                                                                                                         
    ██   ██                                                                                                                         
    ██   ██                                                                                                                         
    ██   ██  █████     ████ ██   ██ ██████  █████  ██████  ████        ██   ██  █████       ██   ██ ██   ██ ██ █ ██ ██   ██  ████   
    ██   ██ ██   ██   ██ ██ ██   ██ █ ██ █ ██   ██ █ ██ █     ██       ██   ██ ██   ██      ██   ██ ██   ██ ██ █ ██ ██   ██     ██  
    ██   ██ ██   ██  ██  ██ ██  ███   ██   ██   ██   ██    █████       ██   ██ ██   ██      ██   ██ ██   ██  █ █ █  ██   ██  █████  
    ██   ██ ██   ██  ██  ██ ██ █ ██   ██   ██   ██   ██   ██  ██       ███████ ███████      ███████ ██   ██  █████  ███████ ██  ██  
    ██   ██ ██   ██  ██  ██ ███  ██   ██   ██   ██   ██   ██  ██       ██   ██ ██           ██   ██ ██   ██  █ █ █  ██   ██ ██  ██  
    ██   ██ ██   ██  ██  ██ ██   ██   ██   ██   ██   ██   ██  ██       ██   ██ ██   ██      ██   ██  ██████ ██ █ ██ ██   ██ ██  ██  
    ██   ██  █████  ███  ██ ██   ██  ████   █████   ████   ███ ██      ██   ██  █████       ██   ██      ██ ██ █ ██ ██   ██  ███ ██ 
                                                                                                         ██                         
                                                                                                    ██   ██                         
                                                                                                     █████

    Политота не нужна

    HomoSapiens, 15 Сентября 2019

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

    +1

    1. 1
    2. 2
    3. 3
    https://tass.ru/nacionalnye-proekty/6391295
    
    Томские ученые разработали первое в России программное обеспечение, независимое от Windows

    ШОК! Томские ученые открыли способ создавать программное обеспечение, независимое от Windows. Нужно всего лишь…

    j123123, 30 Апреля 2019

    Комментарии (44)
  6. Assembler / Говнокод #24779

    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
    .def temp = r16
    .def rr1 = r17
    .org 0
    Ldi r16, low(RAMEND)
    out SPL, temp
    Ldi r16 high(RANEND)
    out SPH, temp
    
    rjmp start
    start:
    ldi temp,255
    out DDRB, temp
    out PORTB,temp
    rcall delay
    Ldi temp,0x00
    out PORTB,temp
    Rcall delay
    rjmp start
    
    delay:
    ldi rr1, 0xFF
    Pdelay:
    Dec rr1
    brne Pdrlay
    ret

    Почему микроконтроллер не мигает лампочка?
    Но студия не ругается
    (Ассемблер АVR)

    Arduino, 17 Сентября 2018

    Комментарии (44)
  7. Куча / Говнокод #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)
  8. Куча / Говнокод #24493

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    Здравствуйте.
    Многие из вас знают пользователя TarasB, который обитал на этом сайте.
    Кто знает какие-либо рабочие контакты, чтобы можно было с ним связаться?
    А то на мыло не отвечает. Может на каких-то ещё форумах он доступен?

    Potap, 13 Июля 2018

    Комментарии (44)
  9. Си / Говнокод #24361

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    LRESULT WINAPI DefWindowProc(
      _In_ HWND   hWnd,
      _In_ UINT   Msg,
      _In_ WPARAM wParam,
      _In_ LPARAM lParam
    );

    CrashTesteAnusov, 06 Июня 2018

    Комментарии (44)
  10. C++ / Говнокод #24024

    +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
    bool almostIncreasingSequence(std::vector<int> sq) {
        bool b2 = true; 
        int s = sq.size(); 
        if (s > 2) {                                           // Последовательность меньше трех чисел дает истину.                          
            int i = 1;                                         // Проверка начинается со второго элемента.                                             
            int x = -1;                                      // Для записи индекса элемента <= предыдущего, а еще "флаг".           
            while ((b2) && (i < s)) {              // При нахождении 2-го лишнего происходит выход из цикла.                                 
                if (x != -1) {                               // Проверка "флага".                                                                                             
                    if (sq[i] <= sq[i - 1]){           // Сравнение с предыдущим элементом.                                                             
                        b2 = false;                        // Если условие истинно, то это уже второй элемент,                                
                    }                                             // "конфликтующий" с предыдущим, следовательно, выход и "ложь".
                    if ((sq[i] <= sq[x - 1]) && (x != 1) && (sq[i - 1] <= sq[x - 2])) {  // над этим условием я думал слишком долго
                        b2 = false;                       // Если элемент был "убран", индекс конфликтного                                   
                    }                                            // элемента записан в "x".                                                                                   
                }     
                else {                                        // Если условие ложно, то записываем индекс элемента, который
                        if (sq[i] <= sq[i - 1]) {     // "конфликтует" с предыдущим.
                            x = i;                             // Нам не известно лишний он или нет.
                        } 
                    }
                i++;
                }
            }
          return b2;
    }

    проверяет, можно ли убрать только один элемент из последовательности, чтобы она стала постоянно возрастающей.

    noserdan, 28 Марта 2018

    Комментарии (44)
  11. C++ / Говнокод #20392

    +3

    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
    #define __DEBUG
    #ifdef __DEBUG
        #define print_pair(p) do{std::cout << "(" << ((p).first + 1) << ", "\
                                << ((p).second + 1) << ")" << std::endl;}while(0);
    #endif
    
    Graph::result
    Graph::dijkstra (int start)
    {
    #ifdef __DEBUG
        std::cout << "Dijkstra algorithm tracing:" << std::endl;
    #endif
        distances[start] = 0;
        std::set<std::pair<int, int>> q;
        q.insert (std::make_pair(distances[start], start));
        while (!q.empty())
        {
    #ifdef __DEBUG
            std::cout << "top element of a set: ";
            print_pair(*q.begin());
    #endif
            int current = q.begin()->second;
            q.erase(q.begin());
            for (int i = 0; i < adj[current].size(); ++i)
            {
    #ifdef __DEBUG
        std::cout << "current vertex: " << (current + 1);
        std::cout << " ad current state of distances array is: " << std::endl;
        for (auto i: distances)
            std::cout << i << " ";
        std::cout << std::endl;
    #endif
                int to = adj[current][i].second;
                int length = adj[current][i].first;
                // Relaxations
                if (distances[to] > distances[current] + length)
                {
    #ifdef __DEBUG
        std::cout << "relaxation for edge (" << current << ", " << to << ") ";
        std::cout << "with weight " << length << std::endl;
    #endif
                    
                    q.erase(std::make_pair(distances[to], to));
                    distances[to] = distances[current] + length;
                    path[to] = current;
                    q.insert(std::make_pair(distances[to], to));
                }
            }
        }
        // Replace INF by -1
        std::replace (distances.begin(), distances.end(), INF, -1);
        return distances;
    }

    Я у мамы решил подебажить как мыщъх дебажил при помощи отладочной печати. Вот что получилось.

    HiewMorjowie, 18 Июля 2016

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